Apple Darwin User Manual Page 18

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 17
#endif
Avoid casting pointers to non pointers. You should generally avoid casting a pointer to a non-pointer type
for any reason (particularly when performing address arithmetic). Alternatives are described in Avoiding
Pointer-to-Integer Conversion (page 22).
Update assembly code. Any assembly code needs to be rewritten because 64-bit Intel assembly language is
significantly different from its 32-bit counterpart. For more information, see Porting Assembly Language
Code (page 27).
Any assembly code that directly deals with the structure of the stack (as opposed to simply using pointers to
variables on the stack) must be modified to work in a 64-bit environment. For more information, see OS X ABI
Mach-O File Format Reference.
Fix format strings. Print functions such as printf can be tricky when writing code to support 32-bit and
64-bit platforms because of the change in the sizes of pointers. To solve this problem for pointer-sized integers
(uintptr_t) and other standard types, various macros exist in the inttypes.h header file.
The format strings for various data types are described in Table 3-1. These additional types, listed in the
inttypes.h header file, are described in Table 3-2.
Table 3-1 Standard format strings
Format stringType
%dint
%ldlong
%lldlong long
%zusize_t
%tdptrdiff_t
%pany pointer
Table 3-2
Additional inttypes.h format strings (where N is some number)
Format stringType
PRIdNintN _t (such as int32_t)
Making Code 64-Bit Clean
General Programming Tips
2012-12-13 | Copyright © 2004, 2012 Apple Inc. All Rights Reserved.
18
Page view 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 ... 67 68

Comments to this Manuals

No comments