C++ D_WIN32_WINNT 编译器警告与 Boost

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3000231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:44:25  来源:igfitidea点击:

D_WIN32_WINNT compiler warning with Boost

c++boostboost-preprocessor

提问by bobber205

Not sure what to make of this error. Added -D_WIN32_WINNT=0x0501to Visual Studio's "Command Line" options under Project Properties but it says it doesn't recognize it and the warning still appears.

不知道如何处理这个错误。添加-D_WIN32_WINNT=0x0501到 Visual Studio 的“项目属性”下的“命令行”选项,但它表示无法识别它并且警告仍然出现。

I am also not sure how to add the Preprocessor Definition.

我也不确定如何添加预处理器定义。

1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
1>- add -D_WIN32_WINNT=0x0501 to the compiler command line; or
1>- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.

1>请适当定义_WIN32_WINNT或_WIN32_WINDOWS。例如:
1>-在编译器命令行中添加-D_WIN32_WINNT=0x0501;或
1>- 将 _WIN32_WINNT=0x0501 添加到项目的预处理器定义中。

采纳答案by foven

I think you're really close to getting this to work. John Dibling gave three ways you could do this and it looks like you tried the third solution, which was to "go in to your project's settings ... and under the Configuration Properties->C/C++->PreProcessorheading, add ;_WIN32_WINNT = 0x0501". You replied that you were still getting that error and provided the contents of your preprocessor settings, WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT = 0x0501. I think you can solve this if you change _WIN32_WINNT = 0x0501to _WIN32_WINNT=0x0501. When I tried the version with spaces, it did not eliminate the error, but removing the spaces did.

我认为你真的很接近让这个工作。John Dibling 提供了三种方法可以做到这一点,看起来您尝试了第三种解决方案,即“进入项目的设置......并在配置属性->C/C++->预处理器标题下,添加;_WIN32_WINNT = 0x0501”。您回答说您仍然收到该错误,并提供了预处理器设置的内容WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT = 0x0501. 我认为如果您更改_WIN32_WINNT = 0x0501_WIN32_WINNT=0x0501. 当我尝试带有空格的版本时,它并没有消除错误,但删除了空格。

回答by John Dibling

A few options.

几个选项。

1) If you have a main header file, like stdafx.h, you could add this:

1) 如果你有一个主要的头文件,比如 stdafx.h,你可以添加:

#define _WIN32_WINNT 0x0501

Or you could add that anywhere you need it.

或者你可以在任何你需要的地方添加它。

2) You can add -D _WIN32_WINNT=0x0501(note the space)

2)可以添加-D _WIN32_WINNT=0x0501(注意空格)

3) Go to Project Properties > Configuration Properties > C/C++ > Proporcessor. Add ;_WIN32_WINNT=0x0501to Preprocessor Definitions.

3) 转到项目属性 > 配置属性 > C/C++ > Proporcessor。添加;_WIN32_WINNT=0x0501预处理器定义

Personally, I choose #3 because there's no doubt about it being defined at the right time in the right translation units, and I'd rather have all the #defines in one place rather than some being in Preprocessor Definesand others in the advanced tab.

就我个人而言,我选择 #3 是因为毫无疑问它会在正确的时间在正确的翻译单元中定义,而且我宁愿将所有 #defines 放在一个地方,而不是一些在Preprocessor Defines 中,而其他一些在高级选项卡中.

回答by Hill

Add following line in your top source code.

在顶部源代码中添加以下行。

#include <SDKDDKVer.h>

回答by Hans Passant

Put a space after the D

在 D 后面放一个空格

回答by Bonga the Poo

For Code Blocks here is how you do it.

对于代码块,这里是你如何做的。

Right click **Project Name** on your left >> Click 'Build Options' >> Select Debug or Release on your left >> Select 'Compiler Settings' Tab on the right >> Select #defines tab >>Then add the following line as it is:

右键单击**Project Name** on your left >> Click 'Build Options' >> Select Debug or Release on your left >> Select 'Compiler Settings' Tab on the right >> Select #defines tab >>然后按原样添加以下行:

_WIN32_WINNT=0x0501

>> Click Ok >> Close >> Right click **Project Name** again >> Re-build.