Solaris 64-bit Developer's Guide

Data Model

As stated previously, the biggest difference between the 32-bit and 64-bit environments is the change in data-type models.

The C data-type model used for 32-bit applications is the ILP32 model, so named because ints, longs, and pointers are 32-bit. The LP64 data model is the C data-type model for 64-bit applications. This model was agreed upon by a consortium of companies across the industry. It is so named because longs and pointers grow to 64-bit quantities. The remaining C types int, short, and char are the same as in the ILP32 model.

The standard relationship between C integral types still holds true.

sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long)

Table 4-1 lists the basic C types, and their corresponding sizes in bits for both the ILP32 and LP64 data type models.

Table 4-1 Data Type Sizes in Bits

C data type 

ILP32 

LP64 

char

unchanged 

short

16 

unchanged 

int

32 

unchanged 

long

32 

64

long long

64 

unchanged 

pointer

32 

64

enum

32 

unchanged 

float

32 

unchanged 

double

64 

unchanged 

long double

128 

unchanged 

It is not unusual for current 32-bit applications to assume that ints, pointers, and longs are the same size. Because the size of longs and pointers change in the LP64 data model, you need to be aware that this change alone can cause many 32-bit to 64-bit conversion problems.

In addition, declarations and casts become very important in showing what is intended; how expressions are evaluated can be affected when the types change. The effects of standard C conversion rules are influenced by the change in data-type sizes. To adequately show what is intended, you might need to declare the types of constants. Casts might also be needed in expressions to make certain that the expression is evaluated the way you intended. This is particularly true in the case of sign extension, where explicit casting might be essential to show intent.

Other problems arise with built-in C operators, format strings, assembly language, and compatibility and interoperability.

The rest of this chapter advises you how to overcome these problems by: