Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically fix missing parenthesis in C

I converted some Fortran code to C. I was wondering if someone could help me solve the following problem:

warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

I know this warning is caused by syntax like this:

A || B && C

Which should be written as:

A || (B && C)

My compiler is able to compile the code since && has a higher priority than || so it just imagines the parentheses.

The problem is that this warning occurs about 30.000 times since I'm working on a large project.

Is there any tool that is able to insert the parenthesis around all the && automatically?

like image 564
user2470258 Avatar asked Jun 10 '13 09:06

user2470258


1 Answers

As others have said do it manually, also you can disable this warning using -Wno-parentheses, even though that's pretty dangerous

like image 177
David Ranieri Avatar answered Nov 11 '22 03:11

David Ranieri