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
Two basic issues that regard conversion arise for applications developers:
Data type consistency and the different data models
Interoperation between applications that use different data models
Trying to maintain a single source with as few #ifdefs as possible is usually better than trying to maintain multiple source trees. This chapter provides guidelines for writing code that works correctly in both 32-bit environments and 64-bit environments. At best, the conversion of current code might require only a recompilation and relinking with the 64-bit libraries. However, for those cases where code changes are required, this chapter discusses the tools that help make conversion easier.