在一个另一个文件中 #include一个**dlg.h文件,会发生dlg的资源ID未定义的错误 :

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'

posted @ 2014-05-19 20:58  fxcl  阅读(446)  评论(0编辑  收藏  举报