I would like to include -Wfloat-equal in my build options (which is the GCC flag that gives a warning when two floating-point numbers are compared using the == or! = Operators). However, in several library header files that I use, and in a large part of my own code, I often want to fork for non-zero float or double values ββusing if (x) or if (x != 0) or variants of this.
Since in these cases I am absolutely sure that the value is zero - the checked values ββare the result of an explicit initialization of zero, calloc , etc. - I see no drawback in using this comparison, but not a much more expensive and less readable call to my function near(x, 0) .
Is there a way to get the -Wfloat-equal effect for all other floating point comparison comparisons, but let them go through unchanged? There are enough of them in the library header files that they can significantly pollute my warning output.
user79758
source share