GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时

GDI+ library causes quot;error C2760: syntax error: unexpected token #39;identifier#39;, expected #39;type specifier#39;quot; in VS2017 when compiled for XP(GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’在 VS2017 中为 XP 编译时) - IT屋-程序员软件开发技术

本文介绍了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.

这篇关于GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时

基础教程推荐