简体   繁体   中英

How to properly include windows.h and set minimum version to XP

I'm currently building a C++ DLL, and I have this at the top of the main DLL .cpp file. This currently is causing the warning "Warning C4005: '_WIN32_WINNT' : macro redefinition" . What have I done wrong?

I need to include windows.h , SDKDDKVer.h and set the minimum windows version to XP. How do I correct my code?

// System Includes
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>

// Windows Version
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>

You should include the SDK stuff first:

// Windows Version
#define _WIN32_WINNT 0x0501     // _WIN32_WINNT_WINXP
#include <SDKDDKVer.h>

// System Includes
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM