首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >安装Visual Studio2010后出现错误C1189

安装Visual Studio2010后出现错误C1189
EN

Stack Overflow用户
提问于 2011-04-30 11:31:48
回答 4查看 30.3K关注 0票数 18

在我使用VS2005之前,我在驱动器崩溃后安装了VS2010,一切都很好。

现在,在编译一个以前还不错的C++应用程序时,我发现了几个错误,我就是找不出来。

错误1错误C1189:#错误:此文件要求_WIN32_WINNT的#定义至少为0x0403。建议使用0x0501或更高的值。C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcore.h 35 1 BIOXGINA

代码语言:javascript
复制
#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);
}

如果我注释掉上面的几行,我就会得到

在下面的第111行上找不到

错误C3861标识符。

我想我之所以得到这个是因为我注释了上面的几行?

代码语言:javascript
复制
HRESULT Init() throw()
{
    HRESULT hRes = S_OK;

111.        if (!InitializeCriticalSectionAndSpinCount(&m_sec, 0))
    {
        hRes = HRESULT_FROM_WIN32(GetLastError());
    }

    return hRes;
}

我将非常感谢在这方面的任何帮助。我真的不想重新安装2005。

EN

回答 4

Stack Overflow用户

发布于 2011-04-30 11:36:25

Microsoft Connect issue具有以下潜在解决方案:

编辑文件"stdafx.h“,并将为_WIN32_WINNT和

定义的值更改为0x0502。

这里有更多关于这个error on the MSDN C++ forum: Problem with older VC Solution的讨论。

票数 24
EN

Stack Overflow用户

发布于 2011-04-30 12:51:12

您的项目所针对的Windows版本不再受较新的编译器(或任何其他版本)的支持。

您必须选择Windows XP ("Windows 5")或更高版本的最低目标版本。

票数 5
EN

Stack Overflow用户

发布于 2011-05-01 12:54:36

感谢你们的回复。

我设法消除了错误消息,如下所示。Context.h看起来像这样。

代码语言:javascript
复制
  #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>

我将#define _WIN32_WINNT 0x0400移到所有includes之后结束,它编译正常。很奇怪,但它起作用了。

但是,我将按照建议将其更改为0x0502。

谢谢

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5839292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档