You can use XL C/C++ to develop both 32-bit and 64-bit applications. To do so, specify -q32 (the default) or -q64, respectively, during compilation.
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.
Table 1. Size and alignment of data types in 32-bit and 64-bit modes
Data type | 32-bit mode | 64-bit mode | ||
---|---|---|---|---|
Size | Alignment | Size | Alignment | |
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 (system-defined unsigned long) | 4 bytes | 4-byte boundaries | 8 bytes | 8-byte boundaries |
ptrdiff_t (system-defined long) | 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:
When compiling in 32-bit or 64-bit mode, you can use the -qwarn64 option to help diagnose some issues related to porting applications. In either mode, the compiler immediately issues a warning if undesirable results, such as truncation or data loss, have occurred.
For suggestions on improving performance in 64-bit mode, see Optimize operations in 64-bit mode.