欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > c/c++ >内容正文

c/c++

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

发布时间:2025/3/20 c/c++ 42 豆豆
生活随笔 收集整理的这篇文章主要介绍了 VC++6.0使用GDI++出现'ULONG_PTR'未定义和'token' 未定义的解决办法 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
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

与50位技术专家面对面20年技术见证,附赠技术全景图

总结

以上是生活随笔为你收集整理的VC++6.0使用GDI++出现'ULONG_PTR'未定义和'token' 未定义的解决办法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。