| November 24, 2008 11:00 PM PST | |
Address Win64* compilation warnings related to improper use of Win64 printf or wsprintf format specifiers. Using improper format specifiers in printf or wsprintf will generate warnings. The warnings might look something like this:
C4313: Calling the printf family of functions with |
During the course of porting applications to the Win64 environment, it is necessary to identify and resolve compiler warnings and errors. The procedure for identifying these errors is addressed in the separate item "How to Use Makefiles to Resolve Win64 Porting Issues."
Use the proper format specifiers to fix this warning. For example, the following code generates a warning because it expects %p to be a 32-bit field:
printf("%p", int_value)
|
It could therefore be modified as follows:
printf("%x",int_value)
|
Likewise, in the case of the following code, %x is a 32 bit field and will truncate the pointer:
printf("%x", ptr_value)
|
It could therefore be modified as follows:
printf("%p",ptr_value)
|
Win64 uses the LLP64 (or P64) uniform data model, in which pointers and long long are 64 bits, but int and long are 32 bits. To support this data model and to provide compatibility with the existing Win32 code, new data types have been defined in Win64.
Porting Microsoft Windows* Applications to Intel® Itanium® Processor Systems
For more complete information about compiler optimizations, see our Optimization Notice.

