Temporarily disable gcc warning on redefinition

c-preprocessorgcc

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?

Best Answer

Try using #undef:

#define FOO ""

#if ....
    #undef FOO
    #define FOO "Foo, good sir"
#endif