- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
两者都用于存储地址和进行指针运算,两者都在 WinAPI 中定义,我什么时候应该使用 uintptr_t
(cstdint) 与 DWORD_PTR
(Windows.h )?在x86和x86_64中分别是32位和64位
A
DWORD_PTR
is anunsigned long
type used for pointer precision. It is used when casting a pointer to anunsigned long
type to perform pointer arithmetic.DWORD_PTR
is also commonly used for general 32-bit parameters that have been extended to 64 bits in 64-bit Windows.
我不打算让我的代码具有可移植性,我坚持使用 WinAPI。什么类型是最佳用例?
最佳答案
首选 uintptr_t
它是 C++11 及更高版本的 C++ 标准的一部分。 DWORD_PTR特定于 Visual C++,因此不可移植。
虽然 Visual C++ 可能会选择将 uintptr_t
实现为 DWORD_PTR
或 unsigned long
,但这取决于他们,坚持使用标准库会更安全。
关于c++ - uintptr_t 与 DWORD_PTR 的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32100059/
下面函数中的DWORD_PTR有什么用 /*static*/ int FRCPACKAGE::ByHash(FRCPACKAGE* frcpackage1, FRCPACKAGE* frcpackag
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 7 年前。 这个问题是由于打字错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在
我正在尝试使用类成员作为回调,但编译器给我以下错误: Error 2 error C2440: 'type cast' : cannot convert from 'void (__stdcall C
实际上是 c++ 的新手。我写了这段代码,但说无法从“waveOutProc”转换为“DWORD_PTR”。你能告诉我如何解决吗? 谢谢 void CALLBACK Audio::waveOutPro
两者都用于存储地址和进行指针运算,两者都在 WinAPI 中定义,我什么时候应该使用 uintptr_t (cstdint) 与 DWORD_PTR (Windows.h )?在x86和x86_64中
为了支持 Win64 的 64 位寻址,Windows API 添加了一些 *_PTR 类型。 SetItemData(int nIndex,DWORD_PTR dwItemData) 当我将第二个参
编译时 #include "windows.h" #include "stdafx.h" #include "resource.h" #include "ProgressDlg.h" ....
有some new integer types在 Windows API 中支持 Win64。他们并不总是得到支持;例如they aren't present in MSVC6 . 我怎样才能写一个
根据 Herb Sutter 的 C++ Coding Standards: 101 Rules, Guidelines, and Best Practices程序员应该避免 C 风格的转换: C-s
*(DWORD_PTR*)&FunctionA = FunctionB( var1, var2, etc...); 这段代码是什么意思?它有什么作用? 我试着用谷歌搜索,但我不知道该用什么词。 前面
我发现 Windows 有一些新的 Windows Data Types DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR 你能告诉我何时、如何以及为
我是一名优秀的程序员,十分优秀!