通过阅读得知:
cassert文件中有:
#ifdef NDEBUG
#define assert(condition) ((void)0)
#else
#define assert(condition) /*implementation defined*/
#endif
所以下面的程序:
#include
// uncomment to disable assert()
#define NDEBUG
#include <cassert>
int main()
{
assert(2+2==4);
std::cout << "Execution continues past the first assert\n";
assert(2+2==5);
std::cout << "Execution continues past the second assert\n";
}
等价于:
#include
// uncomment to disable assert()
#define NDEBUG
#include <cassert>
int main()
{
((void)0);//等价于;
std::cout << "Execution continues past the first assert\n";
((void)0);//等价于;
std::cout << "Execution continues past the second assert\n";
}
[此贴子已经被作者于2016-9-12 19:33编辑过]