[英]error C1189 after installing Visual Studio 2010
I installed VS2010 after a drive crash, prior I had VS2005 and everything was fine.我在驱动器崩溃后安装了 VS2010,之前我有 VS2005,一切都很好。
Now on compiling a C++ app that was fine previously I am seeing a couple of errors which I just cannot figure out.现在在编译以前很好的 C++ 应用程序时,我看到了一些我无法弄清楚的错误。
Error 1 error C1189: #error: This file requires _WIN32_WINNT to be #defined at least to 0x0403.
错误 1 错误 C1189: #error: 此文件要求 _WIN32_WINNT 至少 #defined 到 0x0403。 Value 0x0501 or higher is recommended.
建议使用 0x0501 或更高的值。 C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcore.h 35 1 BIOXGINA
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcore.h 35 1 BIOXGINA
#ifndef __ATLCORE_H__
#define __ATLCORE_H__
#pragma once
#ifdef _ATL_ALL_WARNINGS
#pragma warning( push )
#endif
#pragma warning(disable: 4786) // identifier was truncated in the debug information
#pragma warning(disable: 4127) // constant expression
#include <atldef.h>
#include <windows.h>
#include <ole2.h>
#include <limits.h>
#include <tchar.h>
#include <mbstring.h>
#include <atlchecked.h>
#include <atlsimpcoll.h>
34. #if _WIN32_WINNT < 0x0403
35. #error This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.
36. #endif
#pragma pack(push,_ATL_PACKING)
namespace ATL
{
/////////////////////////////////////////////////////////////////////////////
// Verify that a null-terminated string points to valid memory
inline BOOL AtlIsValidString(
_In_z_count_(nMaxLength) LPCWSTR psz,
_In_ size_t nMaxLength = INT_MAX)
{
(nMaxLength);
return (psz != NULL);
}
If I comment out the above lines, I then get如果我注释掉以上几行,我会得到
error C3861 Identifier not found on line 111 below.
错误 C3861 在下面的第 111 行找不到标识符。
I presume I'm only getting this because I commented the above lines?我想我只是因为我评论了上述几行而得到了这个?
HRESULT Init() throw()
{
HRESULT hRes = S_OK;
111. if (!InitializeCriticalSectionAndSpinCount(&m_sec, 0))
{
hRes = HRESULT_FROM_WIN32(GetLastError());
}
return hRes;
}
I would appreciate any assistance on this.我将不胜感激这方面的任何帮助。 Don't really want to reinstall 2005.
真的不想重新安装2005。
This Microsoft Connect issue has this potential solution:此Microsoft Connect 问题具有以下潜在解决方案:
edit file "stdafx.h" and change the value defined for _WIN32_WINNT and WINVER to 0x0502.
编辑文件“stdafx.h”并将为 _WIN32_WINNT 和 WINVER 定义的值更改为 0x0502。
More discussion here about this error on the MSDN C++ forum: Problem with older VC Solution .更多关于MSDN C++ 论坛上的此错误的讨论:旧 VC 解决方案的问题。
Your project targets a Windows version that is no longer supported by the newer compiler (or anything else).您的项目以 Windows 版本为目标,较新的编译器(或其他任何东西)不再支持该版本。
You have to select a minimum target version that is Windows XP ("Windows 5") or later.您必须 select 最低目标版本是 Windows XP(“Windows 5”)或更高版本。
Project Property –> Configuration Properties –> C/C++ -> Command Line ->Additional Options :add this code Project Property –> Configuration Properties –> C/C++ -> Command Line ->Additional Options :添加这段代码
/D “_WIN32_WINNT=0×0501” /D “_WIN32_WINNT=0×0501”
if in Windows server 2003,0×0501chagnes to 0×0502; if in Windows 7, 0×0501chagnes to 0×0601如果在 Windows 服务器 2003,0×0501 更改为 0×0502; 如果在 Windows 7, 0×0501 更改为 0×0601
works well效果很好
Thank you both for the replies.谢谢两位的回复。
I managed to get rid of the error message as follows.我设法摆脱了错误消息,如下所示。 The Context.h looked liked this.
Context.h 看起来像这样。
#pragma once
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <winwlx.h>
#include <ObjBase.h>
#include <comdef.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <vector>
I moved the #define _WIN32_WINNT 0x0400 to then end after all the includes, and it compiled Ok.我将#define _WIN32_WINNT 0x0400 移动到所有包含后结束,它编译好了。 Odd, but it worked.
奇怪,但它奏效了。
I will however alter it to 0x0502 as suggested.但是,我将按照建议将其更改为 0x0502。
thanks谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.