C++变量在32位系统和64位系统的区别
2013-12-08 16:54
274 查看
Let's describe here only types which can be of interest for developers when porting applications. These types are shown in Table 3. Most recompilation errors will relate to using these very types.
Table 3. Types to be noted while porting 32-bit programs on 64-bit Windows systems.
Type | Type's size on x32 / x64 platform | Note |
---|---|---|
int | 32 / 32 | Basic type. On 64-bit systems remains 32-bit. |
long | 32 / 32 | Basic type. On 64-bit Windows systems remains 32-bit. Keep in mind that in 64-bit Linux systems this type was extended to 64-bit. Don't forget about it if you develop code which should be compiled for Windows and Linux systems. |
size_t | 32 / 64 | Basic unsigned type. The type's size is chosen in such a way that you could write the maximum size of a theoretically possible array into it. You can safely put a pointer into size_t type (except for pointers to class functions, but this is a special case). |
ptrdiff_t | 32 / 64 | Similar to size_t type but this is a signed type. The result of the expression where one pointer is subtracted from the other (ptr1-ptr2) will have ptrdiff_t type. |
Pointer | 32 / 64 | The size of the pointer directly depends on the platform's size. Be careful while converting pointers to other types. |
__int64 | 64 / 64 | Signed 64-bit type. |
DWORD | 32 / 32 | 32-bit unsigned type. In WinDef.h is defined as:typedef unsigned long DWORD; |
DWORDLONG | 64 / 64 | 64-bit unsigned type. In WinNT.h is defined as:typedef ULONGLONG DWORDLONG; |
DWORD_PTR | 32 / 64 | Unsigned type in which a pointer can be placed. In BaseTsd.h is defined as:typedef ULONG_PTR DWORD_PTR; |
DWORD32 | 32 / 32 | 32-bit unsigned type. In BaseTsd.h is defined as:typedef unsigned int DWORD32; |
DWORD64 | 64 / 64 | 64-bit unsigned type. In BaseTsd.h is defined as:typedef unsigned __int64 DWORD64; |
HALF_PTR | 16 / 32 | A half of a pointer. In Basetsd.h is defined as:#ifdef _WIN64 typedef int HALF_PTR;#else typedef short HALF_PTR;#endif |
INT_PTR | 32 / 64 | Signed type in which a pointer can be placed. In BaseTsd.h is defined as:#if defined(_WIN64) typedef __int64 INT_PTR; #else typedef int INT_PTR;#endif |
LONG | 32 / 32 | Signed type which remained 32-bit. That's why in many cases LONG_PTR now should be used. In WinNT.h is defined as:typedef long LONG; |
LONG_PTR | 32 / 64 | Signed type in which a pointer can be placed. In BaseTsd.h is defined as:#if defined(_WIN64) typedef __int64 LONG_PTR; #else typedef long LONG_PTR;#endif |
LPARAM | 32 / 64 | Parameter for sending messages. In WinNT.h is defined as:typedef LONG_PTR LPARAM; |
SIZE_T | 32 / 64 | Analog of size_t type. In BaseTsd.h is defined as:typedef ULONG_PTR SIZE_T; |
SSIZE_T | 32 / 64 | Analog of ptrdiff_t type. In BaseTsd.h is defined as:typedef LONG_PTR SSIZE_T; |
ULONG_PTR | 32 / 64 | Unsigned type in which a pointer can be placed. In BaseTsd.h is defined as:#if defined(_WIN64) typedef unsigned __int64 ULONG_PTR;#else typedef unsigned long ULONG_PTR;#endif |
WORD | 16 / 16 | Unsigned 16-bit type. In WinDef.h is defined as:typedef unsigned short WORD; |
WPARAM | 32 / 64 | Parameter for sending messages. In WinDef.h is defined as:typedef UINT_PTR WPARAM; |
相关文章推荐
- c、c++变量在64位机器和32位机器的区别
- 32位和64位系统内置数据变量的大小区别
- 32位系统和64位系统的区别
- NSInteger在64位和32位系统上区别
- 【386w.com——菜鸟收藏:64位和32位系统之间的区别】
- 【装机吧】Win7电脑系统32位和64位区别(详细版)
- 32位和64位系统区别及int字节数
- 64位系统与32位系统区别
- 64位系统下建立的C++ 项目在32位系统下运行
- 【windows系统32位和64位的区别】
- 32位和64位系统区别及int字节数
- Linux asm系统调用:32位和64位的区别
- 32位和64位系统区别及int字节数
- 32位和64位系统区别及int字节数
- 32位C/C++程序移植到64位系统时需要注意的问题
- 32位和64位系统区别及int字节数
- 64位系统和32位系统区别
- 32位系统和64位系统变量所占空间总结
- 32位和64位系统区别及字节对齐
- C++ 32位程序枚举64位系统注册表子项,含关闭重定向和提权