问题描述:

在VC6环境中,一个界面工程利用了GDI+的一些库,Release模式下编译、运行无误,但在Debug模式下就会报告错误。

xxx.cpp

D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h() : error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h() : error C2059: syntax error : 'newline'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2059: syntax error : 'newline'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2238: unexpected token(s) preceding ';'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2059: syntax error : 'newline'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2238: unexpected token(s) preceding ';'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2059: syntax error : 'newline'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2238: unexpected token(s) preceding ';'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afx.h() : error C2059: syntax error : 'newline'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2802: static member 'operator new' has no formal parameters
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2333: 'new' : error in function declaration; skipping function body
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2802: static member 'operator new' has no formal parameters
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : error C2556: 'void *(__cdecl *__stdcall CNoTrackObject::operator new(void))(unsigned int,const char *,int)' : overloaded function differs only by return type from 'void *(__c
decl *__stdcall CNoTrackObject::operator new(void))(unsigned int)'
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtls_.h() : see declaration of 'new'
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2059: syntax error : 'string'
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2091: function returns function
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2802: static member 'operator new' has no formal parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2333: 'new' : error in function declaration; skipping function body
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2059: syntax error : 'string'
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2090: function returns array
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2059: syntax error : 'return'
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2238: unexpected token(s) preceding ';'
D:\ debug\UI\../ui/gdi/Includes/GdiplusBase.h() : error C2143: syntax error : missing ';' before '}'
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusHeaders.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusImageAttributes.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusMatrix.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusBrush.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusPen.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusStringFormat.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusPath.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusPath.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusLineCaps.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusGraphics.h() : error C2504: 'GdiplusBase' : base class undefined
D:\ debug\UI\../ui/gdi/Includes/GdiplusRegion.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusRegion.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusFontCollection.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusFontFamily.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusFont.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiplusBitmap.h() : error C2661: 'new' : no overloaded function takes parameters
D:\ debug\UI\../ui/gdi/Includes/GdiPlus.h() : error C2143: syntax error : missing ';' before '}'
D:\ debug\UI\../ui/gdi/Includes/GdiPlus.h() : error C2143: syntax error : missing ';' before '}'
D:\ debug\UI\../ui/gdi/Includes/GdiPlus.h() : error C2143: syntax error : missing ';' before '}'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2809: 'operator new' has no formal parameters
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new() : see declaration of 'new'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2059: syntax error : 'string'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2091: function returns function
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' : could not deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator<_Ty> &)' from 'void *(__cdecl *)(unsigned int)'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' and 'void *(__cdecl *__cdecl operator new(void))(unsigned int
)' have different return types
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : see declaration of 'new'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2809: 'operator new' has no formal parameters
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\memory() : error C2954: template definitions cannot nest
D:\ debug\UI\SkinManager.cpp() : error C2661: 'new' : no overloaded function takes parameters
执行 cl.exe 时出错.
Creating browse info file...
.exe - error(s), warning(s)

错误提示

出错原因:

错误提示的那个CPP文件中,将这部分 宏定义的头部去掉。

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif /*
因为此时DEBUG版本中的new 已经被另外一个宏定义过了。Debug下系统调用new的时候果然不是听从基类GdiplusBase中new的,
而是Afx.h中那里的new(这时的确有三个参数),按理系统编译到这里应该提示出错在这行:*/
#ifndef _GDIPLUSBASE_H
#define _GDIPLUSBASE_H class GdiplusBase
{
public:
void (operator delete)(void* in_pVoid)
{
DllExports::GdipFree(in_pVoid);
}
void* (operator new)(size_t in_size)
{
return DllExports::GdipAlloc(in_size);
}
void (operator delete[])(void* in_pVoid)
{
DllExports::GdipFree(in_pVoid);
}
void* (operator new[])(size_t in_size)
{
return DllExports::GdipAlloc(in_size);
}
}; #endif

GdiplusBase.h

跟踪错误:

1、到达AFX.H的

   void* PASCAL operator new(size_t nSize);
void* PASCAL operator new(size_t, void* p);
void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine); // non-_DEBUG_ALLOC version that assume everything is OK
#define DEBUG_NEW new

再加上系统自动生成的下面两行:

#ifdef _DEBUG
#define new DEBUG_NEW

即Debug下系统调用new的时候果然不是听从基类GdiplusBase中new的,而是Afx.h中那里的new(这时的确有三个参数),按理系统编译到这里应该提示出错在这行:
void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
但它下面这行代码:#define DEBUG_NEW new(THIS_FILE, __LINE__)使得出错行提示又在我的代码中调用new的这行:
m_instance = new UIManger();  //采用单例模式

系统将三个参数的默认new 关键字的参数个数。

结果:将上述删除后,Debug就可通过。

附述: 

发现很多下载的用Gdi+的例子在Debug下都有下面这样的错误:
gdiplus.lib(imagingguds.obj) : fatal error LNK1103: debugging information corrupt; recompile module

出现环境 xp sp2 + 最新 sdk + vc6 +vc7

出现此错误 位 vc6 下编译,问题出来 lib 和 link.exe 版本不合;

查看 lib 设置,将 sdk 移动到最后, 编译通过。
看来 xp 的 sdk 已经默认的向 vc.net 靠拢了

链接:http://bbs.csdn.net/topics/80358847

GDI+ 应用,Release没有错误,Debug很多。的更多相关文章

  1. MFC中release版本和debug版本区别

    最近MFC写了个程序,生成release版,原来正常,后来删掉了些控件再编译运行,结果竟然报内存读写错误,debug却是正常的.后来将“Project   Settings”   中   “C++/C ...

  2. GDI+中发生一般性错误的解决办法(转帖)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现“GDI+中发生一般性错误”的异常.于是开始“ ...

  3. Release 版本和 Debug 版本

    什么是 Release 版本.Debug 版本? bug-缺陷,程序故障.而debug指的是排除缺陷,显然这个模式是面向开发者的. 而release是满足发布所用. Debug 和 Release,在 ...

  4. 【转】GDI+中发生一般性错误的解决办法

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现“GDI+中发生一般性错误”的异常. 于是开始 ...

  5. GDI+中发生一般性错误的解决办法(转)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现"GDI+中发生一般性错误" ...

  6. GDI+中发生一般性错误的解决办法(转载)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现"GDI+中发生一般性错误" ...

  7. GDI+ 中发生一般性错误。

    GDI+ 中发生一般性错误. “/wechat”应用程序中的服务器错误. GDI+ 中发生一般性错误. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及 ...

  8. [转载]GDI+中发生一般性错误

    注:第一次写博客,把自己遇到的问题和收集的资料记录在博客上.在开发.NET应用中,使用 System.Drawing.Image.Save 方法而导致“GDI+ 中发生一般性错误”的发生,通常有以下三 ...

  9. GDI+中发生一般性错误(转载)

    在开发.NET应用中,使用 System.Drawing.Image.Save 方法而导致“GDI+ 中发生一般性错误”的发生,通常有以下三种原因:1. 相应的帐户没有写权限.解决方法:赋予 NETW ...

  10. GDI+ 中发生一般性错误(在 OutputStream 中保存 PNG 格式图像时遇到的问题)

    在将图片以 PNG 格式保存至 Response.OutputStream 时,会碰到如下错误: GDI+ 中发生一般性错误. 原因: 在写 PNG 格式的图像时,指针需要在存储的位置来回移动.而 R ...

随机推荐

  1. NOR和NAND

    NOR和NAND NOR和NAND是现在市场上两种主要的非易失闪存技术.Intel于1988年首先开发出NOR flash技术,彻底改变了原先由EPROM和EEPROM一统天下的局面.紧接着,198? ...

  2. sap表维护工具来维护自定义表&视图簇的使用

    一.通过表维护工具维护自定义表 1.SE11创建表 2.se11界面的菜单:实用程序->Table Maintenance Generator其实这里就是调用SE54 3.sm30 调用维护好的 ...

  3. 小记:Touchpad 禁用和启用

    最近上课要背着电脑到处跑,不能带外接键盘,打字时候总会碰到触控版导致光标乱飘,看了下wiki,发现有简单的命令开启或者禁用触控版,记录如下 禁用: # synclient TouchpadOff=1 ...

  4. 大道至简第一章读后感Java伪代码

    //一.愚公移山 /*原始需求 惩山北直塞,出入之迁也. 项目沟通的方式 聚室而谋 项目目标 毕力平险,指通豫南,达于汉阴 人员组成 愚公,子孙荷担者三夫,邻人遗男 技术方案 叩石垦壤 簸萁运与渤海之 ...

  5. python函数前篇

    函数:函数是指将一组语句的集合通过一个函数名封装起来,要想执行这个函数,只需调用其函数名即可 函数特性: 减少重复代码 使程序变得可扩展 使程序变得易维护 什么是函数? 函数就是具备某一特定功能的工具 ...

  6. iOS之 Category 属性 的理解

    在 Objective-C 中可以通过 Category 给一个现有的类添加属性,但是却不能添加实例变量 反正读第一遍的时候我是有点晕的,可以添加“属性”,然后又说“添加实例变量”,第一感觉就好像 有 ...

  7. sqoop1.4.6从mysql导入hdfs\hive\hbase实例

    //验证sqoop是否连接到mysql数据库sqoop list-tables --connect 'jdbc:mysql://n1/guizhou_test?useUnicode=true& ...

  8. scp命令,用来在本地和远程相互传递文件,非常方便

    scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.可能会稍微影响一下速度.当你服务器 ...

  9. windows 系统下C++实现的多线程

    摘抄http://blog.csdn.net/huyiyang2010/article/details/5809919 Thread.h #ifndef __THREAD_H__ #define __ ...

  10. Problem K

    Problem Description The local toy store sells small fingerpainting kits with between three and twelv ...