Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的程序中使用 assert 时遇到了一个奇怪的问题。即使我添加了一行代码,程序也不会终止assert(false)。但是assert当我编写几行示例代码时就可以了。有人知道为什么会这样吗?
assert(false)
assert
如果你有:
#define NDEBUG
这会将所有assert的 ' 变成nop'。
nop
如果您有不同的行为,具体取决于代码量,那么我猜您没有NDEBUG定义,我猜编译器只是在编译冗余代码。
NDEBUG
需要有关环境的更多详细信息,但是,您要给出明确的答案。