D_WIN32_WINNT compiler warning with Boost

非 Y 不嫁゛ 提交于 2019-11-29 02:29:31

问题


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

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:


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++->PreProcessor heading, 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 = 0x0501 to _WIN32_WINNT=0x0501. When I tried the version with spaces, it did not eliminate the error, but removing the spaces did.




回答2:


A few options.

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

#define _WIN32_WINNT 0x0501

Or you could add that anywhere you need it.

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

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

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 Defines and others in the advanced tab.




回答3:


Add following line in your top source code.

#include <SDKDDKVer.h>



回答4:


Put a space after the D




回答5:


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:

_WIN32_WINNT=0x0501

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


来源:https://stackoverflow.com/questions/3000231/d-win32-winnt-compiler-warning-with-boost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!