C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

Data Model Macros
Table 60 lists predefined macros that are set based on the data model specified on the compiler
command-line. They are used when writing source code that is intended to be compiled in both
data models.
Table 60 Data Model Macros
What it definesMacro
Defined automatically, when the data model specified
(explicitly or implicitly) is ILP32. Its value is 1.
_ILP32
Defined automatically, when the data model specified is
LP64. Its value is 1.
_LP64
New Intrinsics <builtin.h>
New Intrinsics defined in header <builtin.h> are as follows:
is_32bit_addr
int _is_32bit_addr(void _ptr64 *);
If the passed pointer is a sign-extended 32-bit address, the function returns a non-zero value.
_ptr64_to_ptr32
The following new builtin insures that a 64-bit pointer safely truncates to a 32-bit pointer:
void _ptr32 * _ptr64_to_ptr32(void _ptr64 *);
If the passed pointer is a sign-extended 32-bit pointer, its low-order 32 bits are returned. Otherwise,
a run-time trap occurs.
NOTE: This intrinsic is not influenced by #pragma no_overflowtraps.
Migration Warnings
The compiler has the ability to detect a number of 64-bit porting issues.
For some issues, the compiler returns a diagnostic by default. For example, any direct assignment
from a 64-bit pointer to a 32-bit pointer returns:
error(611): a value of type "<longpointertype>" cannot be assigned to
an entity of type "<shortpointertype>"
In addition, the compiler provides a feature to return additional warnings. These warnings detect
valid C/C++ code that potentially behaves in an unexpected fashion when code designed for the
ILP32 data model is compiled using the LP64 data model.
This feature is controlled by a command line directive. On Windows and OSS, the option is
--Wmigration_check=32to64. On Guardian, the option is migration_check 32to64.
An example of one of these diagnostics is:
Any conversion (using either a cast or a direct assignment) from a long to an int returns:
warning(2412): 64 bit migration: type conversion may truncate value
Another example is:
Any conversion either from a pointer to long to a pointer to int, or from a pointer to int
to a pointer to long, returns:
warning(2414): 64 bit migration: type conversion may cause target
of pointers to have a different size
HP recommends that you compile the code with the migration check warnings enabled, and each
warning examined, before compiling it with -Wlp64 option.
394 LP64 Data Model