C语言 的断言 assert 只有一个参数,Java 许多其他语言 的断言 可以多传一个字符串参数如,assert a>

问题描述:

C语言 的断言 assert 只有一个参数,Java 许多其他语言 的断言 可以多传一个字符串参数如,assert a>=0,"a should never less than zero\n"; C语言里面只能这样写 assert (a >= 0); 断言失败时没有其他提示,请问C语言有其他断言方式吗?不局限于某个库某个平台
1个回答 分类:综合 2014-11-14

问题解答:

我来补答
先看官方解释:
assert( exp );
The assert() macro is used to test for errors. If exp evaluates to zero, assert() writes information to stderr and exits the program. If the macro NDEBUG is defined, the assert() macros will be ignored.
也就是说,assert后 程序会推迟,在debug下会有提示是在哪里退出的.
既然会退出,何必在意提示的内容呢.
 
 
展开全文阅读
剩余:2000
上一页:算数过程
下一页:enjoy的反义词