Definition of the basic type model of C/C ++/Java/C #

Source: Internet
Author: User

C/C ++ only defines the relationship between basic data types (character length: CHAR <= SHORT <= INT <= LONG), and does not strictly define their character length, according to different implementations of the compiler, their word lengths are shown in the following table:

DATETYPE

LP32

ILP32

LP64

ILP64

LLP64

JAVA

C #

CHAR

8

8

8

8

8

16

16

BYTE

N/

N/

N/

N/

N/

8

8

SHORT

16

16

16

16

16

16

16

_ INT32

N/

32

N/

N/

N/

N/

N/

INT

16

32

32

64

32

32

32

LONG

32

32

64

64

32

64

64

LONG

64

64

64

64

64

N/

N/

POINTER

32

32

64

64

64

N/

N/

FLOAT

32

32

32

32

32

32

32

DOUBLE

64

64

64

64

64

64

64

BOOL

T/F

T/F

T/F

T/F

T/F

T/F

T/F

In the preceding table, LP64, ILP64, and LLP64 are data models with long words on 64-bit platforms. ILP32 and LP32 are data models with long words on 32-bit platforms.

LP64 indicates that the LONG/POINTER length is 64-bit;
ILP64 indicates that the length of INT/LONG/POINT is 64-bit;
LLP64 indicates that the length of LONGLONG/POINTER is 64-bit;
ILP32 indicates that the length of INT/LONG/POINTER is 32 characters;
LP32 indicates that the LONG/POINT character length is 32 characters, and the INT character length is 16 characters.
Note: The ILP32 data model is used for-bit Windows, and the LLP64 data model is used for 64-bit Windows.

Note: 2: 32-bit Linux/Unix uses the ILP32 data model, and 64-bit Linux/Unix uses the LP64 data model.

NOTE 3: To increase code portability, print the number of unsigned integers, regardless of how they are defined during the declaration, use % lu.

Note 4: To ensure the versatility of the platform, do not use the long database type in the code.

Note 5: When INT is used, intptr_t can also be used to ensure the versatility of the platform. It has different compilation lengths on different platforms, but is a standard platform length. For example: the length of a 64-bit machine is 8 bytes, and that of a 32-bit machine is 4 bytes.

Note 6: When writing code, use sizeof whenever possible to calculate the data type size.

Note 7: ssize_t and size_t are signsize_t and unsigned signed size of computer word size, respectively. They are also the word lengths of computers. They are int type on 32-bit machines and long type on 64-bit machines. In a sense, they are equivalent to intptr_t and uintptr_t.

 

The data type in WINDOWS is defined as follows:

Type

Definition

Type

Definition

DWORD32

32-bit unsigned integer

DWORD64

64-bit unsigned integer

INT32

32-bit signed integer

UINT32

32-bit unsigned integer

INT64

64-bit signed integer

UINT64

64-bit unsigned integer

LONG32

32-bit signed integer

ULONG32

32-bit unsigned integer

LONG64

64-bit signed integer

ULONG64

64-bit unsigned integer

DWORD_PTR

Pointer precision unsigned long integer

 

 

HALF_PTR

Half pointer size, signed

UHALF_PTR

Half pointer size, unsigned

INT_PTR

Pointer progress signed integer

UINT_PTR

Pointer progress unsigned integer

LONG_PTR

Signed long integer of pointer progress

ULONG_PTR

Unsigned long integer of pointer progress

SIZE_T

Maximum number of bytes available for pointers

SSZIE_T

Signed SIZE_T

LPARAM

Synonym for LONG_PTR

WPARM

Synonym for UINT_PTR

POINTER_32

32-bit pointer type

POINTER_64

64-bit pointer type

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.