在一个另一个文件中 #include一个**dlg.h文件,会发生dlg的资源ID未定义的错误 :
2014-05-19 20:58
375 查看
1 在一个另一个文件中 #include一个**dlg.h文件,会发生dlg的资源ID未定义的错误 :
dlg1.h(23) : error C2065: 'IDD_DIALOG1' : undeclared identifier
最简单的方法是在dlg的.h文件头加入 : #include "resource.h"
2 debug assertion failed!
“ASSERT()或VERIFY()语句:这两个宏是用来测试它的参数是否为真的。出现错误这说明你的指针或表达试有问题 。
出错原因肯定就在ASSERT()或VERIFY()语句上,可能空指针、内存泄漏,条件不足、野指针和数组写越界.等等 ”
野指针是指同一个内存区域被释放了两次..
数组写越界就是对超出数组下界的区域进行写数据.
我的错误是 野指针,注释了这行就搞定了 ://delete lpParameter;
在MSDN上:
Evaluates its argument.
ASSERT( booleanExpression)
Parameters
booleanExpression
Specifies an expression (including pointer values) that evaluates to nonzero or 0.
Remarks
If the result is 0, the macro prints a diagnostic message and aborts the program. If the condition is nonzero, it does nothing.
The diagnostic message has the form
assertion failed in file <name> in line <num>
where name is the name of the source file, and num is the line number of the assertion that failed in the source file.
In
the Release version of MFC, ASSERT does not evaluate the expression and
thus will not interrupt the program. If the expression must be
evaluated regardless of environment, use the VERIFY macro in place of
ASSERT.
Note This function is available only in the Debug version of MFC.
In
an MFC ISAPI application, an assertion in debug mode will bring up a
modal dialog box (ASSERT dialog boxes are now modal by default); this
will interrupt or hang the execution. To suppress modal assertion
dialogs, add the following lines to your project source file
(projectname.cpp):
// For custom assert and trace handling with WebDbg
#ifdef _DEBUG
CDebugReportHook g_ReportHook;
#endif
Once
you have done this, you can use the WebDbg tool (WebDbg.exe) to see the
assertions. For information on using the WebDbg tool, see Viewing Trace
Messages And Handling Asserts.
Example
// example for ASSERT
CAge* pcage = new CAge( 21 ); // CAge is derived from CObject.
ASSERT( pcage!= NULL )
ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CAge ) ) )
// Terminates program only if pcage is NOT a CAge*.
3 warning C4312 : conversion from 'LONG' to 'WNDPROC' of greater size
据说,这是因为32位/64位的问题,编译器是警告你代码到64位环境下可能会出问题。
类型转换不要用(LONG_PTR),LongToPtr(),也不要直接用(WNPROC),而是用(WNDPROC)LongToPtr()。
warning C4311: 'type cast' : pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'LONG'
dlg1.h(23) : error C2065: 'IDD_DIALOG1' : undeclared identifier
最简单的方法是在dlg的.h文件头加入 : #include "resource.h"
2 debug assertion failed!
“ASSERT()或VERIFY()语句:这两个宏是用来测试它的参数是否为真的。出现错误这说明你的指针或表达试有问题 。
出错原因肯定就在ASSERT()或VERIFY()语句上,可能空指针、内存泄漏,条件不足、野指针和数组写越界.等等 ”
野指针是指同一个内存区域被释放了两次..
数组写越界就是对超出数组下界的区域进行写数据.
我的错误是 野指针,注释了这行就搞定了 ://delete lpParameter;
在MSDN上:
Evaluates its argument.
ASSERT( booleanExpression)
Parameters
booleanExpression
Specifies an expression (including pointer values) that evaluates to nonzero or 0.
Remarks
If the result is 0, the macro prints a diagnostic message and aborts the program. If the condition is nonzero, it does nothing.
The diagnostic message has the form
assertion failed in file <name> in line <num>
where name is the name of the source file, and num is the line number of the assertion that failed in the source file.
In
the Release version of MFC, ASSERT does not evaluate the expression and
thus will not interrupt the program. If the expression must be
evaluated regardless of environment, use the VERIFY macro in place of
ASSERT.
Note This function is available only in the Debug version of MFC.
In
an MFC ISAPI application, an assertion in debug mode will bring up a
modal dialog box (ASSERT dialog boxes are now modal by default); this
will interrupt or hang the execution. To suppress modal assertion
dialogs, add the following lines to your project source file
(projectname.cpp):
// For custom assert and trace handling with WebDbg
#ifdef _DEBUG
CDebugReportHook g_ReportHook;
#endif
Once
you have done this, you can use the WebDbg tool (WebDbg.exe) to see the
assertions. For information on using the WebDbg tool, see Viewing Trace
Messages And Handling Asserts.
Example
// example for ASSERT
CAge* pcage = new CAge( 21 ); // CAge is derived from CObject.
ASSERT( pcage!= NULL )
ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CAge ) ) )
// Terminates program only if pcage is NOT a CAge*.
3 warning C4312 : conversion from 'LONG' to 'WNDPROC' of greater size
据说,这是因为32位/64位的问题,编译器是警告你代码到64位环境下可能会出问题。
类型转换不要用(LONG_PTR),LongToPtr(),也不要直接用(WNPROC),而是用(WNDPROC)LongToPtr()。
warning C4311: 'type cast' : pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'LONG'
相关文章推荐
- kettle保存资源库报错:一个数据库错误发生在从资源库文件读取转换时
- 由于未能找到 id 为“ctl19”的控件或在回发后将同一 ID 分配给另一个控件,导致发生错误。
- 关于包含头文件而编译时却一个未定义错误的原因(未使用命名名字空间)
- Android中通过反射获取资源Id(特别用在自己定义一个工具将其打成.jar包时,特别注意资源的获取)
- php中在一个php文件调用另一个php的函数,保存登录时保存的用户id
- 定义一个colors.xml颜色资源文件
- VC 如何Copy一个项目的资源文件中的对话框到另一个项目
- C语言学习笔记----伊能C语言学习笔记----如何在一个文件中使用另一个文件中定义的变量呢??
- 总结:C# Bitmap保存的问题,eg:GDI+中发生一般性错误 .jpg 正由另一个进程使用 ,该进程无法访问文件
- android library工程中使用switch_case语句,调用资源文件的id出现错误的原因分析及解决方法
- 【Android 如何置底一个View(附 前置声明layout布局文件中的资源ID)】
- 不同XML文件定义同一个ID
- 启动Mysql时发生的一个关于PID文件错误问题
- 郁闷N天了,IDFTP发生10054错误后无法继续上传文件,重新创建IDFTP后发生错误:550 cannot create file。请教解决方法
- VC 如何Copy一个项目的资源文件中的对话框到另一个项目
- (转)C++头文件相互引用,最好一个#include,另一个class C;
- PHP error_log()将错误信息写入一个文件(定义和用法)
- 定义一个colors.xml颜色资源文件
- MFC更改控件ID后,cpp文件显示错误“未定义的标识符”
- 触发器引起"事务(进程 ID 88)与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务。"的错误