std::assert 发生了什么 [英] What happened to std::assert
问题描述
这个答案和大量重复表明我应该使用 #include <c*>
对于我从 C++ 代码中提取的 C 头文件,我应该用 std::*
调用它们.
This answer and it's multitude of duplicates indicate that I should be using #include <c*>
for the C headers that I pull from in C++ code, and that I should be calling them with std::*
.
我一直在这样做,但我注意到一个例外.std::assert
似乎没有被定义,即使我正确地#include
.
I have been doing that but I notice an exception. std::assert
doesn't seem to be defined, even when I correctly #include <cassert>
.
这是怎么回事?这是实施疏忽,还是实际例外?
What's going on here? Is this an implementation oversight, or an actual exception?
推荐答案
assert
是一个宏,而不是一个函数.因此,它需要与普通的旧 assert(condition)
一起使用.
assert
is a macro, not a function. Hence, it needs to be used with plain old assert(condition)
.
这是一个支持链接:http://en.cppreference.com/w/cpp/错误/断言.
这篇关于std::assert 发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!