fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at l
2013-11-14
fatal error C1189: #error :This file requires _WIN32_WINNT to be #defined at l我现在用VS2010,打开以
fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at l 我现在用VS2010,打开以前版本的工程编译时报上述错误, 如何解决? [解决办法] 要是有预编译的话 在预编译开始定义 #define _WIN32_WINNT 0x0501 其他看情况定义这个 [解决办法]
+1 [解决办法] 唉,看到上面的回答我表示很无奈,我也遇到过这个问题,差点折腾死我。我的环境是VS2010+Windows Server 2008 r2.上面的问题不能完美的解决。我来说一下我摸出来的一个规则。之前我也参照他们的这些说法瞎折腾,但是还是报错,然后我新建了一个VC的项目,然后对比了一下突然发现VS会自动生成targetver.h这个文件,打开看只有两行代码。 #pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h> 以后大家遇到这个问题就新建一个h文件,把上面的代码复制进去,然后在工程的stdafx.h的顶部添加 include"targetver.h",记得删除所有类似下面的代码: #ifndef WINVER// 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。 #define WINVER 0x0400//为 Windows98 和 Windows 2000 及更新版本改变为适当的值。 #endif
#ifndef _WIN32_WINNT// 允许使用 Windows NT 4 或更高版本的特定功能。 #define _WIN32_WINNT 0x0400//为 Windows98 和 Windows 2000 及更新版本改变为适当的值。 #endif
#ifndef _WIN32_WINDOWS// 允许使用 Windows 98 或更高版本的特定功能。 #define _WIN32_WINDOWS 0x0410 //为 Windows Me 及更新版本改变为适当的值。 #endif