How can I know if the DWORD_PTR type is defined using ifdef?


Memsize-types DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR and ULONG_PTR are intended to support 64-bit code and can safely store a pointer regardless of the platform capacity. But these types might be absent in old versions of Windows Platform SDK. The best solution of this problem is to update SDK to the latest version. However, if it is impossible for some reason, you can define these types by yourself.

Since these types are defined by the typedef specifier, there is no single reliable method to check their presence in the SDK version being used with the help of the #ifdef directive at the preprocessing step. However, the maximum value for these types is defined through MAXULONG_PTR in the basetsd.h file and you may do the following:

#if !defined(MAXULONG_PTR)
typedef DWORD DWORD_PTR;
#endif

References



Use PVS-Studio to search for bugs in C, C++, C# and Java

We offer you to check your project code with PVS-Studio. Just one bug found in the project will show you the benefits of the static code analysis methodology better than a dozen of the articles.

goto PVS-Studio;



Bugs Found

Checked Projects
364
Collected Errors
13 504