0
我想将一个h文件包含到我的项目中,并且发现一些错误。该程序正常工作。我真的需要包含的H文件, 我甚至试图改变一些东西,但仍然存在,我的项目中也存在同样的问题。将一个头文件包含到我的MVS项目中时出错
问题的来源以粗体文字列出。
代码如上。
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; //最后TOOLINFO结构
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需要使用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
请向我们展示_your_代码,而不是系统头文件。在包含此系统头文件之前,代码中可能存在一些问题。 – 2013-02-27 12:19:06
问题出在两条粗线上,而不是在我的cpp文件中。这些问题一出现在我的cpp文件#include的顶部,就出现了这三个问题。 – MelMed 2013-02-27 12:21:22
系统头文件中的错误_manifests_,但它不在系统头文件中。在包含此头文件之前,您很可能错过了分号。 – 2013-02-27 12:25:07