C/C++ : Guidelines - Porting to 64bit Operating Systems


Guidelines to remember while porting C/C++ Applications to 64-bit mode

• Data Truncation
• Avoid assigning longs to ints
• Avoid Storing Pointers in ints
• Avoid Truncating Function Return Values
• Use Appropriate Print Specifiers

• Data Type Promotion
• Avoid Arithmetic between Signed and Unsigned Numbers

• Pointers
• Avoid Pointer Arithmetic between longs and ints
• Avoid Casting Pointers to ints or ints to Pointers
• Avoid Storing Pointers in ints
• Avoid Truncating Function Return Values

• Structures
• Avoid Using Unnamed and Unqualified Bit Fields
• Avoid Passing Invalid Structure References

• Hardcoded Constants
• Avoid Using Literals and Masks that Assume 32 bits
• Avoid Hardcoding Size of Data Types
• Avoid Hardcoding Bit Shift Values
• Avoid Hardcoding Constants with malloc(), memory(3), string(3)


Links:
Migrating to 64-Bit Environments - http://www.informit.com/guides/printerfriendly.asp?g=cplusplus&seqNum=201
Porting to a 64-bit Platform - http://www.devx.com/Intel/Article/27237/2217?pf=true
HP-UX 64-bit Porting Concepts - http://docs.hp.com/en/5966-9844/ch03.html
HP-UX 64-bit Porting and Transition Guide: HP 9000 Computers - http://docs.hp.com/en/5966-9887/
Target 32- and 64-bit Platforms Together with a Few Simple Datatype Changes -http://www.devx.com/cplus/Article/27510/1954?pf=true