C++ 错误 C1189:#error:此文件要求将 _WIN32_WINNT 至少定义为 0x0500。推荐值 0x0501 或更高

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14643962/
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-27 18:32:50  来源:igfitidea点击:

error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended

c++windowsvisual-studio-2010mfc

提问by Alexander Mashin

I create MFC project in VS2010(windows xp). And i take this error:

我在 VS2010(windows xp) 中创建了 MFC 项目。我接受这个错误:

error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended. 

if I added in afxcomctl32.h: #define _WIN32_WINNT 0x0501, i take 60+ errors. In project i dont added anything. Use such as Visual Studio created. What i need to do with this?

如果我添加afxcomctl32.h: #define _WIN32_WINNT 0x0501,我会出现 60 多个错误。在项目中我没有添加任何东西。使用如 Visual Studio 创建。我需要怎么做?

回答by duDE

afxcomctl32.h is a wrong place I think, to fix this problem make your stdafx.h looking like this:

我认为 afxcomctl32.h 是一个错误的地方,为了解决这个问题,让你的 stdafx.h 看起来像这样:

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER                // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif                        

#ifndef _WIN32_WINDOWS        // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE            // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0500    // Change this to the appropriate value to target IE 5.0 or later.
#endif

回答by aldo

Try adding this to the TOP of your StdAfx.h file:

尝试将其添加到 StdAfx.h 文件的顶部:

#include <sdkddkver.h>

In my application, I'm defining

在我的应用程序中,我定义

_WIN32_WINNT=_WIN32_WINNT_WINXP

At first I had the same problem. I discovered that because when you use MFC, you're not allowed to include windows.h, _WIN32_WINNT_WINXP is never definedand so _WIN32_WINNT didn't have a valid value. By including the header that windows.h uses to define those values (sdkddkver.h), suddenly everything works!

起初我遇到了同样的问题。我发现因为当您使用 MFC 时,您不允许包含 windows.h,_WIN32_WINNT_WINXP从未定义过,因此 _WIN32_WINNT 没有有效值。通过包含 windows.h 用来定义这些值的头文件 (sdkddkver.h),突然一切正常!

Blech. I hate programming for Windows.

布莱克。我讨厌为 Windows 编程。

回答by strannik

You don't need to modify afxcomctl32.h. You just need to include Windows.h before this file.

您不需要修改 afxcomctl32.h。您只需要在此文件之前包含 Windows.h。

Should work.

应该管用。

回答by Alexander Mashin

I solved my problem. The fact was that the file atmcore.hwas different from the standart in VS2010.

我解决了我的问题。事实是该文件atmcore.h与 VS2010 中的标准不同。