error C2872: “Font”: 不明确的符号

在VS2010中调用GDI+时,

Font font(&fontFamily,24,FontStyleRegular,UnitPixel);

会提示提示“Font”: 不明确的符号的问题

1>          可能是“c:/program files/microsoft visual studio 10.0/vc/include/comdef.h(312) : Font”
1>          或       “c:/program files/microsoft sdks/windows/v7.0a/include/gdiplusheaders.h(244) : Gdiplus::Font”

解决方法:

把#include <GdiPlus.h>
#pragma comment(lib, "gdiplus.lib")

using namespace Gdiplus;

放到系统的头文件之前才行,

原错误代码修改为Gdiplus::Font font(&fontFamily,24,FontStyleRegular,UnitPixel);

原文地址:https://www.cnblogs.com/AlexanderZhao/p/12878986.html