I'm trying to make this work (in GCC 4.6) without barking at me.
#define FOO "" #define BAR "" #if .... #define FOO "Foo, good sir" #endif #if ... #define BAR "Bar, my lady" #endif .... #define EVERYTHING FOO BAR ...
I am going to have a lot of these. So doing it that way instead of:
#if ... #define FOO "Foo" #else #define FOO "" #endif
Saves a lot of code, and makes it more readable. The warning that I get is:
warning: "FOO" redefined [enabled by default]
Is there a way to disable this warning in the code for this particular section? I found Diagnostic Pragmas to disable certain warnings, but I'm not able to find which warning (in this list of Options to Request or Suppress Warnings) that needs to be disabled here.
Anyone know how to do this? Or a different way to avoid having to #else #define
all of them to the empty string?
The warning message for each controllable warning includes the option that controls the warning. That option can then be used with -Werror= and -Wno-error= as described above. (Printing of the option in the warning message can be disabled using the -fno-diagnostics-show-option flag.)
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
Maybe you can look for CFLAGS options in Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.
You can use the -Werror compiler flag to turn all or some warnings into errors. Show activity on this post. You can use -fdiagnostics-show-option to see the -W option that applies to a particular warning.
Try using #undef
:
#define FOO "" #if .... #undef FOO #define FOO "Foo, good sir" #endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With