Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX 64-bit Porting and Transition Guide: HP 9000 Computers > Chapter 5 Writing Portable Code

Making Code 64-bit Clean

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

If your application is targeted for execution on both ILP32 and LP64, it should be 64-bit clean. Tools to help make your code 64-bit clean include:

  • using lint,

  • compiling in ANSI C or aC++, and

  • using the portable header file <inttypes.h>.

To make code 64-bit clean, follow these guidelines:

  • Use the same source code and header files for both 32-bit and 64-bit programs.

  • Use appropriate data types consistently and strictly.

    For example, use off_t consistently for file offsets and fpos_t for file positions.

  • Use integral types in <inttypes.h>, where applicable, instead of int and long

  • Use fixed/scalable width integral types, algorithms, and masks as appropriate.

    Fixed types remain a consistent size on 32-bit and 64-bit platforms. For example, use int32_t, defined in <inttypes.h>, if ints and longs should be 32 bits in your application. Scalable types can grow and scale without modification to future architectures.

  • Perform boundary checking on integral type ranges.

  • Update 64-bit code in cases where 32-bit and 64-bit processes share the same memory segment.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.