Using 32-bit and 64-bit modes
You can use the IBM® Open XL C/C++ compiler to develop either 32-bit or 64-bit applications.
To do so, specify -m32 (the default) or -m64, respectively, during compilation. Alternatively, you can set the OBJECT_MODE environment variable to 32 or 64 at compile time. If both OBJECT_MODE and -m32/-m64 are specified, -m32/-m64 takes precedence.
However, porting existing
applications from 32-bit to 64-bit mode can lead to a number of problems, mostly
related to the differences in C/C++ long and pointer data type sizes and
alignment between the two modes. The following table summarizes these differences.
Data type | 32-bit mode | 64-bit mode | ||
---|---|---|---|---|
Size | Alignment | Size | Alignment | |
long, signed long, unsigned long | 4 bytes | 4-byte boundaries | 8 bytes | 8-byte boundaries |
pointer | 4 bytes | 4-byte boundaries | 8 bytes | 8-byte boundaries |
size_t (defined in the header file <cstddef>) | 4 bytes | 4-byte boundaries | 8 bytes | 8-byte boundaries |
ptrdiff_t (defined in the header file <cstddef>) | 4 bytes | 4-byte boundaries | 8 bytes | 8-byte boundaries |
The following sections discuss some of the common pitfalls implied by these differences, as well as recommended programming practices to help you avoid most of these issues: