您的位置:首页 > 编程语言 > C语言/C++

VC++6.0使用GDI++出现'ULONG_PTR'未定义和'token' 未定义的解决办法

2012-02-03 11:32 701 查看
VC++6.0使用GDI++出现'ULONG_PTR'未定义和'token' 未定义的解决办法

http://hi.baidu.com/programpad/blog/item/5e479f4dfd58a8f1d62afc45.html

2009-04-16 18:20
在引用gdiplus头文件之前声明,#define ULONG_PTR ULONG,既可



昨天有朋友说按照我的另一篇文章《[原创]在VC++6.0中如何使用GDI+》的方法使用GDI++,但是会出现错误,我看了看他发来的程序,报的错误是这样的:

e:\codebox\monitor\gdi\gdiplusinit.h(39) : error C2065: 'ULONG_PTR' : undeclared identifier

e:\codebox\monitor\gdi\gdiplusinit.h(39) : error C2065: 'token' : undeclared identifier

e:\codebox\monitor\gdi\gdiplusinit.h(39) : error C2165: 'left-side modifier' : cannot modify pointers to data

e:\codebox\monitor\gdi\gdiplusinit.h(39) : error C2071: 'NotificationHookProc' : illegal storage class

e:\codebox\monitor\gdi\gdiplusinit.h(40) : error C2146: syntax error : missing ')' before identifier 'token'

e:\codebox\monitor\gdi\gdiplusinit.h(40) : error C2165: 'left-side modifier' : cannot modify pointers to data

e:\codebox\monitor\gdi\gdiplusinit.h(40) : error C2071: 'NotificationUnhookProc' : illegal storage class

e:\codebox\monitor\gdi\gdiplusinit.h(40) : error C2059: syntax error : ')'

e:\codebox\monitor\gdi\gdiplusinit.h(91) : error C2059: syntax error : 'const'

e:\codebox\monitor\gdi\gdiplusinit.h(97) : error C2146: syntax error : missing ')' before identifier 'token'

e:\codebox\monitor\gdi\gdiplusinit.h(97) : warning C4229: anachronism used : modifiers on data are ignored

e:\codebox\monitor\gdi\gdiplusinit.h(97) : error C2182: 'GdiplusShutdown' : illegal use of type 'void'

e:\codebox\monitor\gdi\gdiplusinit.h(97) : error C2059: syntax error : ')'

e:\codebox\monitor\monitornetwork.h(23) : error C2146: syntax error : missing ';' before identifier 'm_pGdiToken'

e:\codebox\monitor\monitornetwork.h(23) : error C2501: 'ULONG_PTR' : missing storage-class or type specifiers

e:\codebox\monitor\monitornetwork.h(23) : error C2501: 'm_pGdiToken' : missing storage-class or type specifiers

E:\codebox\monitor\MonitorNetWork.cpp(133) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data

E:\codebox\monitor\MonitorNetWork.cpp(171) : error C2065: 'm_pGdiToken' : undeclared identifier

问题原因:GDI++是WIndows Platform SDK不是MFC的一部分,而ULONG_PTR在SDK中的定义与MFC中的定义相冲突,所以,会出现此问题。

解决办法:添加#define ULONG_PTR ULONG ,具体如下:

#pragma comment(lib, "gdi//gdiplus.lib")

#define ULONG_PTR ULONG

#include "gdi/GdiPlus.h"

using namespace Gdiplus;

由于疏忽,忘记在那篇文章中写清,抱歉,如以往的所有文章出现问题,请将问题发到我的邮箱:liuzairenjian@163.com

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐