The header file inttypes.h provides
type definitions for integer types that are guaranteed to have a specific
size (for example, int32_t and int64_t, and
their unsigned variations). Consider using those type definitions
if your program code relies on types with specific sizes.
There are many ways to use headers to handle code
that is portable between ILP32 and LP64. You can minimize the amount
of conditional compilation code and avoid having totally different
sections of code for a ILP32 and LP64 structure definitions if you
adopt a coding convention that suits your environment.
If you provide a library to your application users
and ship header files that define the application programming interface
of the library, consider shipping a single set of headers that can
support both 32-bit and 64-bit versions of your library. You can use
the type definitions in
inttypes.h. For example, if you
are currently shipping 32-bit versions of your header files, you could:
- Replace all fields of type long with type int32_t (or
another 32-bit type)
- Similarly replace all fields for the unsigned variation
- If you cannot let a 64-bit application use a 64-bit pointer for
a field, use the __ptr32 qualifier.