Open System Services Programmer's Guide
◦ Casting an int to a pointer can cause errors when the pointer is de-referenced.
◦ Casts between long* to int* are problematic because the object of a long pointer is
64 bits in size, but the object of an int pointer is only 32 bits in size.
◦ Functions that return pointers, when declared implicitly, can return truncated values.
◦ Comparing an int to a pointer can cause unexpected results.
◦ Avoid pointer arithmetic between long and int. Pointer arithmetic is a source of difficulty
in migration.
◦ Avoid casting a pointer to an int or an int to a pointer.
◦ Avoid storing a pointer in an int.
◦ Avoid truncating function return values.
• Data Alignment and Data Sharing – Data alignment rules determine where fields are located
in memory. There are differences between the LP64 data alignment rules and the ILP32 data
alignment rules.
In ILP32, pointer and long data types are 32 bits wide and are aligned on 32-bit boundaries.
In LP64, pointer and long are 64 bits wide and are aligned on 64-bit boundaries.
Applications that do not consider alignment differences between ILP32 and LP64 can have
trouble sharing binary data. Data exchanged between ILP32 and LP64 programs, whether
via files, remote procedure calls, or other messaging protocols, might not be aligned as
expected.
• #pragma shared2/shared8 — When compiled with the LP64 data model, the compiler
will issue an error for components with either a long or pointer data type that does not have
an explicit size modifier. (However, these types of components are still allowed for the ILP32
data model.)
• Hardcoded Constants – When a program with hexadecimal constants is ported from ILP32
to LP64, the data types assigned to the constants might change. The following table illustrates
some common hex constants and their types:
Table 53 Hex Constants and Types
LP64 Data ModelILP32 Data ModelConstant
intint0x7fffffff
longlong0x7fffffffL
unsigned intunsigned int0x80000000
longunsigned long0x80000000L
In LP64, 32-bit hexadecimal constants might not set pointers or masks to the correct value. In
LP64, the first 32 bits of 64-bit pointers contain significant information.
◦ Avoid using literals and masks that assume 32 bits
◦ Avoid hardcoding size of data types
Converting 32-Bit Applications to 64-Bit Applications 309