【问题标题】:Syntax error in MFC headerMFC 标头中的语法错误
【发布时间】:2016-08-04 06:13:03
【问题描述】:

我正在尝试编译 pgpfone,但我从 VS6 迁移到 VS2008,然后迁移到 VS2015 的构建系统出现问题。

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /I.\ /I..\common /I..\bignum /I..\..\..\libs\pfl\win32 /I..\..\..\libs\pfl\common /I..\..\..\libs\pfl\common\util /ZI /nologo /W2 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _WINDOWS /D PGP_WIN32=1 /D PGPXFER=1 /D PGP_INTEL=1 /D BNINCLUDE=bni80386c.h /D _VC80_UPGRADE=0x0600 /Gm /EHsc /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo".\Debug/" /Fd".\Debug/vc140.pdb" /Gd /TP /analyze- /errorReport:queue ..\common\ADPCM.cpp ..\common\blowfish.cpp ..\common\bytefifo.cpp ..\common\cast5.cpp ..\common\CControlThread.cpp ..\common\CCounterEncryptor.cpp ..\common\CEncryptionStream.cpp ..\common\CMessageQueue.cpp ..\common\CPFPackets.cpp ..\common\CPFTransport.cpp ..\common\CPipe.cpp ..\common\CPriorityQueue.cpp ..\common\crc.cpp ..\common\CSoundInput.cpp ..\common\CSoundOutput.cpp ..\common\CXferThread.cpp ..\common\des3.cpp ..\common\dh.cpp ..\common\DHPrimes.cpp ..\common\fastpool.cpp ..\common\HashWordList.cpp ..\common\PGPFoneUtils.cpp ..\common\samplerate.cpp ..\common\SHA.cpp CAuthWindow.cpp CEncryptionDialog.cpp CFileTransferDialog.cpp CLevelMeter.cpp CModemDialog.cpp CPFTInternet.cpp CPFTSerial.cpp CPFWindow.cpp CPGPFone.cpp CPGPFoneFrame.cpp CPGPFStatusBar.cpp CPhoneDialog.cpp CSoundLight.cpp CStatusPane.cpp CTriThreshold.cpp CWinFilePipe.cpp CXferWindow.cpp LMutexSemaphore.cpp LSemaphore.cpp LThread.cpp PGPFWinUtils.cpp
  PGPFWinUtils.cpp
  _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
atlmfc\include\afxrendertarget.h(142): warning C4003: not enough actual parameters for macro 'IsNull' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2059: syntax error: '(' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2143: syntax error: missing ')' before '==' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2143: syntax error: missing ',' before '==' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2059: syntax error: '==' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2059: syntax error: ')' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2059: syntax error: '{' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]
atlmfc\include\afxrendertarget.h(142): error C2334: unexpected token(s) preceding '{'; skipping apparent function body [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]

这是完整的日志: https://ci.appveyor.com/project/ysangkok/pgpfone

如何找出导致错误的原因?我假设 PGPFWinUtils.cpp 的代码包含一个错误调用宏的标头,导致错误,但我不知道那会在哪里。

Visual C++ 是否有可能获得宏回溯?我记得 Clang 或 GCC 有这个功能。

这里是完整的来源:https://github.com/ysangkok/pgpfone/blob/master/src/win32/PGPFWinUtils.cpp

我在 AppVeyor 上编译,我本地没有 afxrendertarget.h 的来源。如何在 Ubuntu 上下载用于标头检查的 Windows SDK?

【问题讨论】:

  • 什么是“宏观回溯”?预处理器输出?您还知道您可以使用远程桌面登录 AppVeyor 实例吗?
  • 检查包含的非 MFC 标头。其中一个可能#define 是一个名为IsNull 的宏,它破坏了MFC 的CD2DSizeF::IsNull() 声明。
  • @stijn:通过宏回溯,我的意思是一个显示宏被调用位置的列表,例如here。我现在将检查 RDP 和非 MFC 标头。
  • @dxiv:你是对的,发布一个答案。

标签: c++ visual-c++ mfc


【解决方案1】:
atlmfc\include\afxrendertarget.h(142): warning C4003: not enough actual parameters for macro 'IsNull' [C:\projects\pgpfone\src\win32\PGPfone.vcxproj]

第一个错误提供了一些线索:

  • afxrendertarget.h中的#142行是CD2DSizeF的成员函数BOOL IsNull() const的内联定义;

  • C4003指的是宏IsNull的非法扩展。

这表明其他一些非 MFC 头文件 #define 是一个宏 IsNull,并且当该头被包含在之前(包含的 MFC 头文件)afxrendertarget.h 时,IsNull 宏会破坏 @987654332 @成员函数声明。

【讨论】:

    猜你喜欢
    • 2011-12-27
    • 1970-01-01
    • 2017-04-24
    • 1970-01-01
    • 2013-01-04
    • 2020-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多