gpt4 book ai didi

c++ - 将一个 header 包含到我的 MVS 项目时出错

转载 作者:行者123 更新时间:2023-11-28 03:22:10 25 4
gpt4 key购买 nike

我正在尝试将 h 文件包含到我的项目中,但我发现了一些错误。该程序运行正常。我真的需要我包含的 H 文件,我什至尝试更改一些东西,但我的项目中仍然存在同样的问题。

问题的根源以粗体列出。

代码如上。

class AFX_MODULE_THREAD_STATE : public CNoTrackObject { public:
AFX_MODULE_THREAD_STATE();
virtual ~AFX_MODULE_THREAD_STATE();

// current CWinThread pointer
CWinThread* m_pCurrentWinThread;

// list of CFrameWnd objects for thread
CTypedSimpleList<CFrameWnd*> m_frameList;

// temporary/permanent map state
DWORD m_nTempMapLock; // if not 0, temp maps locked
CHandleMap* m_pmapHWND;
CHandleMap* m_pmapHMENU;
CHandleMap* m_pmapHDC;
CHandleMap* m_pmapHGDIOBJ;
CHandleMap* m_pmapHIMAGELIST;

// thread-local MFC new handler (separate from C-runtime)
_PNH m_pfnNewHandler;

#ifndef _AFX_NO_SOCKET_SUPPORT
// WinSock specific thread state
HWND m_hSocketWindow;
#ifdef _AFXDLL
CEmbeddedButActsLikePtr<CMapPtrToPtr> m_pmapSocketHandle;
CEmbeddedButActsLikePtr<CMapPtrToPtr> m_pmapDeadSockets;
CEmbeddedButActsLikePtr<CPtrList> m_plistSocketNotifications;
#else
CMapPtrToPtr* m_pmapSocketHandle;
CMapPtrToPtr* m_pmapDeadSockets;
CPtrList* m_plistSocketNotifications;
#endif
#endif

// common controls thread state
CToolTipCtrl* m_pToolTip;
CWnd* m_pLastHit; // last window to own tooltip
INT_PTR m_nLastHit; // last hittest code

TOOLINFO* m_pLastInfo; // last TOOLINFO structure

INT_PTR m_nLastStatus;      // last flyby status message
CControlBar* m_pLastStatus; // last flyby status control bar
};

#if (_WIN32_WINNT >= 0x600)
#ifndef _WINSOCK2API_
#ifdef _WINSOCKAPI_

#error MFC requires use of Winsock2.h

#endif
#include <winsock2.h>
#endif

...

至于错误如下:

- 1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxstat_.h(172): error C2143: syntax error : missing ';' before '*'

- 1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxstat_.h(172): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

- 1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxstat_.h(172): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

- 1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h(112): fatal error C1189: #error : MFC requires use of Winsock2.h

最佳答案

您发布的代码既不包含守卫也不包含 #pragma once 也不包含 header 或前向声明,因此我认为它不完整。因此,这有点猜测,但也许有帮助:

  • 第一个问题似乎是编译器不知道 TOOLINFO 是什么 - 可能缺少一些包含或者您以某种方式弄乱了 namespace ,#defines 或其他包括该 header 之前的事情。
  • 第二个问题是您直接或间接包含了 Winsock.h,它与必须用于 MFC 的 Winsock2.h 冲突。

结论:可以肯定地说您在某处弄乱了代码,但错误显示在包含的 header 中的时间很晚,而且似乎与造成困惑的最初原因无关。

关于c++ - 将一个 header 包含到我的 MVS 项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15111933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com