Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Programming Guide
 Common Visual C++ 64-bit Migration ...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual C++ 
Common Visual C++ 64-bit Migration Issues 

When you use Visual C++ to create applications to run on a 64-bit Windows operating system, you should be aware of the following issues:

  • An int and a long are 32-bit values on 64-bit Windows operating systems. For programs that you plan to compile for 64-bit platforms, you should be careful not to assign pointers to 32-bit variables. Pointers are 64-bit on 64-bit platforms, and you will truncate the pointer value if you assign it to a 32-bit variable.

  • size_t, time_t, and ptrdiff_t are 64-bit values on 64-bit Windows operating systems.

  • time_t is a 32-bit value on 32-bit Windows operating systems in Visual C++ versions before Visual C++ 2005. In Visual C++ 2005 and later, time_t is a 64-bit integer by default. For more information, see Time Management.

    You should be aware of where your code takes an int value and processes it as a size_t or time_t value. It is possible that the number could grow to be larger than a 32-bit number and data will be truncated when it is passed back to the int storage.

The %x (hex int format) printf modifier will not work as expected on a 64-bit Windows operating system. It will only operate on the first 32 bits of the value that is passed to it.

  • Use %I32x to display an integer on a Windows 32-bit operating system.

  • Use %I64x to display an integer on a Windows 64-bit operating system.

  • The %p (hex format for a pointer) will work as expected on a 64-bit Windows operating system.

For more information, see:

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
The part about %x just doesn't make any sense      Lance Uppercut   |   Edit   |   Show History

It says that %x will only display the first 32 bits of the value. In C language %x expects an argument of type 'unsigned int', which is 32 bits in Visual C++ on this 64 bit platform. This means that %x should perfectly well display an 'unsigned int' without any extra effort. Moreover, this also means that %x will work exactly as expected. What were they trying to say with that "won't work as expected" and "%I32x"? Why do they suggest using "%I64x" to display an integer if they just said that integers are 32 bits on that platform? That's just some kind of nonsense.

Tags What's this?: Add a tag
Flag as ContentBug
Others 64 bit portability issues      CodeX64   |   Edit   |   Show History
You can find other interesting information about 64-bit Migration Issues by reference: http://www.Viva64.com/articles.php
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker