int_ptr, long_ptr這些類型的含义
来源:互联网 发布:js的insertbefore参数 编辑:程序博客网 时间:2024/05/20 13:37
The *_PTR
types were added to the Windows API in order to support Win64's 64bit addressing.
Because 32bit APIs are used to store pointers to things using data types like DWORDS
, it was necessary to create new types for 64 bit compatibility that acted like a DWORD
in 32bits, but were extended to 64bits when used in a 64bit app.
So, for example, application developers who want to write code that works as 32bit OR 64bit the windows 32bit API SetWindowLong(HWND,int,LONG)
was changed to SetWindowLongPtr(HWND,int,LONG_PTR)`
In a 32bit build, SetWindowLongPtr
is simply a macro that resolves to SetWindowLong
, and LONG_PTR
is likewise a macro that resolves to LONG
. In a 64bit build on the other hand, SetWindowLongPtr
is an API that accepts a 64bit long as its 3rd parameter, and ULONG_PTR
is typedef for unsigned __int64
.
By using these _PTR
types, one codebase can compile for both Win32 and Win64 targets.
When performing pointer arithmetic, these types should also be used in 32bit code that needs to be compatible with 64bit.
so, if you need to access an array with more than 4billion elements, you would need to use an INT_PTR rather than an INT
CHAR* pHuge = new CHAR[0x200000000]; // allocate 8 billion bytes INT idx; INT_PTR idx2; pHuge[idx]; // can only access the 1st 4 billion elements. pHuge[idx2]; // can access all 64bits of potential array space.
目的是为了在32位系统和64位系统保持兼容。举例来说, INT_PTR在32位系统下表示32bit的值,在64位系统下可表示64位的值。
就是这样。
- int_ptr, long_ptr這些類型的含义
- int_ptr, long_ptr這些類型的含义
- 关于INT_PTR的理解
- INT_PTR 更好的移植性
- INT_PTR 更好的移植性
- int( (LONG)(LONG_PTR)&(((type *)0)->field))的最好解释
- 解决VC提示 syntax error : identifier 'LONG_PTR'错误的方法
- int( (LONG)(LONG_PTR)&(((type *)0)->field))的最好解释
- 解决VC提示 syntax error : identifier 'LONG_PTR'错误的方法
- int( (LONG)(LONG_PTR)&(((type *)0)->field))的最好解释
- INT_PTR,DWORD_PTR...
- (VC++)请问INT_PTR 是什么?
- "/"的含义
- /的含义
- $的含义
- *&的含义
- 在运行MFC程序的Release版本时,断点断在"INT_PTR nResponse = dlg.DoModal();"这句话上的处理
- error C2061: syntax error : identifier 'LONG_PTR'
- C#正则表达式(5):命名空间System.Text.RegularExpressions下面的类简介2
- Session和Cookie的一些事
- c语言不使用中间变量交换两个数
- delphi获取dll的函数列表
- OSGi服务发布和获取方式
- int_ptr, long_ptr這些類型的含义
- repo常见命令用法与说明
- word中参考文献[1]、[2]等可以直接生成
- js 中的字符替换
- python创建目录
- java关键字大全
- 进程的内核空间共享
- ora-00031:session marked for kill处理oracle中杀不掉的锁
- sql server中利用sql语句如何创建角色和用户