如何正确地包含windows.h并将最低版本设置为XP [英] How to properly include windows.h and set minimum version to XP

查看:251
本文介绍了如何正确地包含windows.h并将最低版本设置为XP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个C ++ DLL,而且我在这个主要的DLL .cpp 文件的顶部。这当前正在导致警告警告C4005:'_WIN32_WINNT':宏重定义。我做错了什么?

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?

我需要包含 windows.h SDKDDKVer。 h 并将最低Windows版本设置为XP。如何更正我的代码?

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>


推荐答案

您应该首先包含SDK的东西:

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>

这篇关于如何正确地包含windows.h并将最低版本设置为XP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆