开发者

typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;

What does exactly this mean?

typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;

Does this mean that *PUINT_PTR is a pointer (obviously) and UINT_PTR is NOT a pointer? If so, why is it called UINT_PTR ? (which I would read as unsigned i开发者_运维百科nt pointer, or pointer to unsigned int)

Thanks


Yes, this means that PUINT_PTR is a pointer and UINT_PTR is not a pointer. It's a little confusing, but a UINT_PTR (as well as the more standardized uintptr_t) is defined to be an unsigned integer that is guaranteed to be large enough to hold a pointer value. It's typically used for tricky code where pointers are put into integer values and vice-versa.

The _W64 annotation is a note to the Miscrosoft compiler that when compiling for a 64-bit target, the variable should be 64 bits wide instead of the usual 32, since on 64-bit platforms, pointers are 64 bits, but unsigned ints are usually still 32 bits. This ensures that sizeof(UINT_PTR) >= sizeof(void*) for all target platforms.

The second declaration just declares PUINT_PTR to be a pointer to a _W64 unsigned int, or more specifically, a pointer to a UINT_PTR.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜