This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/49928] New: Only workaround for "-Wundef" is "defined(Macro) && Macro", but it is undefined behavior?
- From: "schaub.johannes at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 1 Aug 2011 04:37:31 +0000
- Subject: [Bug preprocessor/49928] New: Only workaround for "-Wundef" is "defined(Macro) && Macro", but it is undefined behavior?
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49928
Summary: Only workaround for "-Wundef" is "defined(Macro) &&
Macro", but it is undefined behavior?
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: schaub.johannes@googlemail.com
It appears that to inhibit a warning about using an undefined macro identifier,
one has to employ the following work-around
#define FOO BAR
#if FOO // warns about 'BAR'
Instead:
#define FOO defined BAR && BAR
#if FOO
Doesn't warn anymore then. But that yields to undefined behavior and IMO it's
not intuitive, because "BAR" is still used but is undefined (this doesn't work
like short circuiting or something), so I would think GCC provides another way
to do this.
If it doesn't exist yet, I would like to ask for a builtin, like
#define FOO __possibly_undefined(BAR) // , or
#define FOO ((BAR))
See https://bugs.webkit.org/show_bug.cgi?id=65401