For 32-bit programs, pointers and the C data types int and long are all 32-bit quantities. For 64-bit programs, pointers and the C data type long
are defined as 64-bit quantities.
The preprocessor symbol _ILP32, made visible by the inclusion of <sys/types.h> can be used with the preprocessor #ifdef
construct to define sections of code that will only be compiled as part of a 32-bit version of a given C program.
The preprocessor symbol _LP64 can be used in the same way to define sections of code that will only be compiled as part of a 64-bit version of a given C program.
For example:
|
#include <sys/types.h>
...
#ifdef _LP64
printf("The data model is LP64 in this environment\n");
#else
#ifdef _ILP32
printf("The data model is ILP32 in this environment\n");
#else
#error "Unknown data model!"
#endif
#endif
|
|