【问题标题】:fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> [duplicate]致命错误 C1189:#error:WINDOWS.H 已包含在内。 MFC 应用程序不得#include <windows.h> [重复]
【发布时间】:2014-04-29 06:49:04
【问题描述】:

我有一个使用 SQL Compact Server 的 Visual Studio 6.0 项目。 我正在尝试更新在 Visual Studio 2012 上使用的解决方案,但出现以下错误:

fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

我的stdafx.h包括winsock2.h,谁有这个:

#ifndef _INC_WINDOWS
#include <windows.h>
#endif /* _INC_WINDOWS */

有办法抑制错误吗?我该如何进行?当我间接删除包含它的文件的 windows.h 时,我得到了error C2011: 'IRowsetBookmark' : 'struct' type redefinition

我已经在此处看到有关此错误的其他问题,但没有任何建议对我有用。


- 更新:

我解决了error C2011: 'IRowsetBookmark' : 'struct' type redefinition 在我的stdafx.h 顶部添加以下行:

#if !defined(__IRowsetBookmark_INTERFACE_DEFINED__)
#define __IRowsetBookmark_INTERFACE_DEFINED__
#endif

#if !defined(__IRowsetBookmark_FWD_DEFINED__)
#define __IRowsetBookmark_FWD_DEFINED__
#endif

但我得到了error C2143: syntax error : missing ',' before '&lt;' 在那一行:

class CArrayRowset :
    public CVirtualBuffer<T>,
    public TRowset
{

是否有可能在我的 stdfx.h 中添加这些行我搞砸了一些类声明?

【问题讨论】:

  • 基于this,在包含winsock2.h之前不包含afx.hafxwin.h可能解决问题吗?
  • 这样我得到了错误 C2011: 'IRowsetBookmark' : 'struct' type redefinition that I提到
  • 至于C2143,我想应该是无关的吧,前面不是有:error C2504: 'CVirtualBuffer' : base class undefined吗?这意味着您必须包含定义它的文件,至少在 VS2013 上,它似乎是 atldbcli.h
  • 这个错误发生在 atldbcli_ce.h

标签: c++ visual-studio-2010 mfc sql-server-ce stdafx.h


【解决方案1】:

尝试在包含 winsock2.h 之前定义 _INC_WINDOWS 以使包含 win.h 无效

【讨论】:

  • 这个_INC_WINDOWS是在windows.h上定义的
  • 这个项目应该是MFC项目吗?如果没有,则需要创建一个非 MFC 项目。
猜你喜欢
  • 2013-05-09
  • 2014-03-10
  • 2015-12-22
  • 2020-06-07
  • 2014-11-29
  • 2016-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多