Using 32-bit and 64-bit modes

You can use the XL C compiler to develop either 32-bit or 64-bit applications. To do so, specify -q32 or -q64, respectively, during compilation. Alternatively, you can set the OBJECT_MODE environment variable to 32 or 64 at compile time. If both OBJECT_MODE and -q32/-q64 are specified, -q32/-q64 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 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, 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:

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, will occur when the program is executed.

For suggestions on improving performance in 64-bit mode, see Optimize operations in 64-bit mode.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us