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?
This warning comes from file named “cccp.c” in gcc (as of 2.95 version; is this file from “Soviet Russia”?), and it can’t be turned off. There is still no option to disable this warning individually even in git head, gcc/libcpp/macro.c file (line 2527 and line 2994 of the same file)
I’ll cite sources a bit.
So in your case
warn_of_redefinitionfunction will return true. And here is real usage:So, there is no any specific option. And answer by Greg is good for this case, just undefine your empty string just before redefinition.