3. Comparing 32-bit Interfaces and 64-bit Interfaces
Implementing Single-Source Code
uintptr_t and Other Helpful Types
Limits Defined by <inttypes.h>
lint for 32-bit and 64-bit Environments
Guidelines for Converting to LP64
Do Not Assume int and Pointers Are the Same Size
Do Not Assume int and long Are the Same Size
Use Pointer Arithmetic Instead of Address Arithmetic
Beware of Implicit Declaration
Use Casts to Show Your Intentions
Check Format String Conversion Operation
Derived Types That Have Grown in Size
Check for Side Effects of Changes
Check Whether Literal Uses of long Still Make Sense
Use #ifdef for Explicit 32-bit Versus 64-bit Prototypes
5. The Development Environment
Assuming you need to convert your code to 64-bit, the following checklist might be helpful:
Read this entire document with an emphasis on the Guidelines for Converting to LP64.
Review all data structures and interfaces to verify that these are still valid in the 64-bit environment.
Include <sys/types.h> in your code to pull in the _ILP32 or _LP64 definitions as well as many basic derived types.
Move function prototypes and external declarations with non-local scope to headers and include these headers in your code.
Run lint(1) using the -errchk=longptr64 and review each warning individually, being aware that not all warnings require a change to the code. Depending on the resulting changes, you might also want to run lint(1) again, both in 32–bit and 64–bit modes.
Compile code as both 32-bit and 64-bit, unless the application is being provided only as 64-bit.
Test the application by executing the 32-bit version on the 32-bit operating system, and the 64-bit version on the 64-bit operating system. You could include testing the 32-bit version on the 64-bit operating system, but this is not necessary.