断言()与消息 [英] assert() with message
本文介绍了断言()与消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只见某处断言与以下列方式的消息用于:
I saw somewhere assert used with a message in the following way:
assert(("message", condition));
这似乎工作的伟大,除了GCC抛出以下警告:
This seems to work great, except that gcc throws the following warning:
warning: left-hand operand of comma expression has no effect
我怎样才能制止警告?
How can I stop the warning?
推荐答案
使用 -Wno-未使用的价值
停止警告; (该选项 -Wall
包括 -Wunused值
)。
Use -Wno-unused-value
to stop the warning; (the option -Wall
includes -Wunused-value
).
我觉得更好的是使用其他方法,如
I think even better is to use another method, like
assert(condition && "message");
这篇关于断言()与消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文