How to make GCC warn of unintentional assignment

When I added the compiler option -Wparentheses, I get a warning

warning: suggest parentheses around assignment used as truth value [-Wparentheses]

for this code

int x;

if (x = 0)
{
}

A condition in an expression is iferroneously assigned instead of a comparison.

Now I want to pass the condition of the function using this macro:

#define check(condition,message) DoCheck(condition, message)

where the actual check for condition!=0is performed in this function DoCheck. I would like to get the same warning for erroneous assignments when I use this macro:

check(x = 0, "bla");

How can I tell GCC that the first parameter should be treated as an operator condition if?

: : 0 == x. - . .

+4

All Articles