I saw somewhere assert used with a message in the following way:
assert(("message", condition));
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?
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");