GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时
我正在尝试将以下 GDI+ 定义包含在我在 Visual Studio 2017 下编译的 Win32 C++ 项目中:
I'm trying to include the following definitions for GDI+ into my Win32 C++ project that is compiled under Visual Studio 2017:
#include <objidl.h>
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")
我需要编译这个项目以支持 Windows XP.所以在我选择的项目属性中:Platform Toolset
as Visual Studio 2017 - Windows XP (v141_xp)
:
I need to compile this project to support Windows XP. So in the project properies I selected: Platform Toolset
as Visual Studio 2017 - Windows XP (v141_xp)
:
但是当我编译它时,GDI+ 库给了我这个:
But when I compile it the GDI+ library gives me this:
1>c:program files (x86)microsoft sdkswindowsv7.1aincludeobjbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusheaders.h(891): error C4596: 'EmfToWmfBits': illegal qualified name in member declaration
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusstringformat.h(220): error C4596: 'GetTrimming': illegal qualified name in member declaration
知道如何解决这个问题吗?
Any idea how to fix this?
推荐答案
在COM相关标头的第一个(!)#include
之前添加此行以修复objbase.h(239):错误 C2760:语法错误:意外标记标识符",预期的类型说明符"
:
Add this line before the very first(!) #include
of COM-related header to fix 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还没有在那个地方宣布.
This fix works, because the line in objbase.h(239)
mentioned in the error contains static_cast<IUnknown*>(*pp);
despite that IUnknown still haven't been declared in that place.
相关文章