TRACE()、ASSERT()、ASSERT_VALID()、Cobject::Dump()的作用
2008-10-16 22:38
281 查看
TRACE()
Provides similar functionality to the printf function by sending a
formatted string to a dump device such as a file or debug monitor. Like
printf for C programs under MS-DOS, the TRACE macro is a convenient way
to track the value of variables as your program executes. In the Debug
environment, the TRACE macro output goes to afxDump. In the Release
environment, it does nothing.
----------
ASSERT
Evaluates its argument. If the result is 0, the macro prints a
diagnostic message and aborts the program. If the condition is nonzero,
it does nothing.
-----
ASSERT_VALID
Use to test your assumptions about the validity of an object’s
internal state. ASSERT_VALID calls the AssertValid member function of
the object passed as its argument.
In the Release version of MFC, ASSERT_VALID does nothing. In the
Debug version, it validates the pointer, checks against NULL, and calls
the object’s own AssertValid member functions. If any of these tests
fails, this displays an alert message in the same manner as ASSERT.
Note This function is available only in the Debug version of MFC.
-------------------
CObject::Dump
virtual void Dump( CDumpContext& dc ) const;
Parameters
dc
The diagnostic dump context for dumping, usually afxDump.
Remarks
Dumps the contents of your object to a CDumpContext object.
When you write your own class, you should override the Dump
function to provide diagnostic services for yourself and other users of
your class. The overridden Dump usually calls the Dump function of its
base class before printing data members unique to the derived class.
CObject::Dump prints the class name if your class uses the
IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL macro.
Note Your Dump function should not print a newline character at the end of its output.
Dump calls make sense only in the Debug version of the Microsoft
Foundation Class Library. You should bracket calls, function
declarations, and function implementations with #ifdef _DEBUG/#endif
statements for conditional compilation.
Since Dump is a const function, you are not permitted to change the object state during the dump.
The CDumpContext insertion (<<) operator calls Dump when a CObject pointer is inserted.
Dump permits only “acyclic” dumping of objects. You can dump a list
of objects, for example, but if one of the objects is the list itself,
you will eventually overflow the stack.
Provides similar functionality to the printf function by sending a
formatted string to a dump device such as a file or debug monitor. Like
printf for C programs under MS-DOS, the TRACE macro is a convenient way
to track the value of variables as your program executes. In the Debug
environment, the TRACE macro output goes to afxDump. In the Release
environment, it does nothing.
----------
ASSERT
Evaluates its argument. If the result is 0, the macro prints a
diagnostic message and aborts the program. If the condition is nonzero,
it does nothing.
-----
ASSERT_VALID
Use to test your assumptions about the validity of an object’s
internal state. ASSERT_VALID calls the AssertValid member function of
the object passed as its argument.
In the Release version of MFC, ASSERT_VALID does nothing. In the
Debug version, it validates the pointer, checks against NULL, and calls
the object’s own AssertValid member functions. If any of these tests
fails, this displays an alert message in the same manner as ASSERT.
Note This function is available only in the Debug version of MFC.
-------------------
CObject::Dump
virtual void Dump( CDumpContext& dc ) const;
Parameters
dc
The diagnostic dump context for dumping, usually afxDump.
Remarks
Dumps the contents of your object to a CDumpContext object.
When you write your own class, you should override the Dump
function to provide diagnostic services for yourself and other users of
your class. The overridden Dump usually calls the Dump function of its
base class before printing data members unique to the derived class.
CObject::Dump prints the class name if your class uses the
IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL macro.
Note Your Dump function should not print a newline character at the end of its output.
Dump calls make sense only in the Debug version of the Microsoft
Foundation Class Library. You should bracket calls, function
declarations, and function implementations with #ifdef _DEBUG/#endif
statements for conditional compilation.
Since Dump is a const function, you are not permitted to change the object state during the dump.
The CDumpContext insertion (<<) operator calls Dump when a CObject pointer is inserted.
Dump permits only “acyclic” dumping of objects. You can dump a list
of objects, for example, but if one of the objects is the list itself,
you will eventually overflow the stack.
相关文章推荐
- AssertValid和Dump 这两个函数的作用
- AssertValid和Dump函数的应用
- assert,assert_valid,verify,trace
- assert,assert_valid,verify,trace用法
- MFC程序中使用调试宏ASSERT()、ASSERT_VALID()、VERIFY()和TRACE()的区别
- VC++的AssertValid和Dump函数的应用详解
- assert,assert_valid,verify,trace用法
- VC的调试中,AssertValid和Dump函数的应用(转载)
- assert,assert_valid,verify,trace用法
- AssertValid和Dump函数的应用
- AssertValid和Dump函数的应用
- AssertValid和Dump函数的应用
- AssertValid()与Dump()函数
- MFC中的AssertValid和Dump函数
- AssertValid与Dump的介绍
- VC的调试中,AssertValid和Dump函数的应用(转)
- VC的调试中,AssertValid和Dump函数的应用(转)
- VC的调试中,AssertValid和Dump函数的应用
- ASSERT_VALID和ASSERT宏分析
- Android官方命令深入分析之dmtracedump