您的位置:首页 > 编程语言 > C语言/C++

assert functions in C/C++/C#

2012-08-03 14:21 330 查看
I just had several small tests. Here is a summary to the assertion related APIs we are using in our product.
Assert Function                                                                Comments
assert                                                                                Just work in debug mode;  standard C assert function
ASSERT                                                                              Just work in debug mode;  MFC assert function
System::Diagnostics::Debug::Assert                                 Works both in debug mode and Release mode; Managed C++ assert function
System.Diagnostics.Debug.Assert                                     Just work in debug mode; C# assert function
Please note above red line, ‘System::Diagnostics::Debug::Assert’ works both in debug and release mode, so if we have following code in managed C++:
System::Diagnostics::Debug::Assert(false, "something wrong");
We would always see the assertion window both in debug and release build. So, in managed C++, we’d better use following code to avoid assertion in Prod-build:
#ifdef DEBUG
System::Diagnostics::Debug::Assert(false, "something wrong");
#endif

转自:http://blog.csdn.net/allenwwg/article/details/6336401
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  diagnostics system mfc c# c