我正在尝试将 GDI+ 的以下定义包含到我在 Visual Studio 2017 下编译的 Win32 C++ 项目中:
#include <objidl.h>
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")
我需要编译这个项目来支持 Windows XP。所以在我选择的项目属性中:
Platform Toolset
如 Visual Studio 2017 - Windows XP (v141_xp)
:但是当我编译它时,GDI+ 库给了我这个:
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\gdiplusheaders.h(891): error C4596: 'EmfToWmfBits': illegal qualified name in member declaration
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\gdiplusstringformat.h(220): error C4596: 'GetTrimming': illegal qualified name in member declaration
知道如何解决这个问题吗?
最佳答案
在第一个 (!) #include
之前添加这一行修复 COM 相关头文件 objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
:
typedef struct IUnknown IUnknown;
此修复程序有效,因为
objbase.h(239)
中的行错误中提到的包含static_cast<IUnknown*>(*pp);
尽管 IUnknown 仍然没有在那个地方声明。
关于c++ - GDI+ 库导致 "error C2760: syntax error: unexpected token ' 标识符',在 VS2017 中为 XP 编译时预期为 'type specifier'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57014731/