Common Visual C++ 64-bit Migration Issues

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:

http://msdn.microsoft.com/en-us/library/3b2e7499(v=vs.80).aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值