致命错误 C1189:#error:窗口。H 已包括在内。MFC 应用不得 #include < Windows.h>

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

本文关键字:#include gt lt Windows 应用 窗口 #error C1189 致命错误 包括 MFC      更新时间:2023-10-16

我有一个使用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

我已经在这里看到了关于这个错误的其他问题,但是没有一个建议适合我。


——更新:

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

#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 '<'在那一行:

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

是否有可能在我的stdfix .h上添加这些行弄乱了一些类声明?

尝试在包含winsock2.h之前定义_INC_WINDOWS