$ cat argh.h #define __x(y) __NR_##y #define x(y) __x(y) /* define HAVE_FOO if __NR_XXX is defined: */ #define __NR_read 0 #undef __NR_write #ifdef BUG2 #define __NR_ac%scess 1 #endif
#if defined XXX # if x(XXX) >= 0 # define HAVE_FOO 1 # warning HAVE_FOO # else # undef HAVE_FOO # warning no FOO # endif #endif $ echo | gcc-4.4-trunk -DXXX=acce%ss -include argh.h -c - -E -P In file included from <command-line>:0: ./argh.h:11:13: error: division by zero in #if ./argh.h:13:4: warning: #warning HAVE_FOO Another (alleged) one, BUG2: $ echo | gcc-4.4-trunk -DBUG2 -DXXX=read -include argh.h -c - -E -P In file included from <command-line>:0: ./argh.h:7:16: warning: missing whitespace after the macro name ./argh.h:13:4: warning: #warning HAVE_FOO And something that would be handy to have but that doesn't seem to work for me: This is Ok, __NR_read is defined: $ echo | gcc-4.4-trunk -DXXX=read -include argh.h -c - -E -P In file included from <command-line>:0: ./argh.h:13:4: warning: #warning HAVE_FOO This is not OK, i'd expect this to be "no FOO" since __NR_write is *not* defined: $ echo | gcc-4.4-trunk -DXXX=write -include argh.h -c - -E -P In file included from <command-line>:0: ./argh.h:13:4: warning: #warning HAVE_FOO -- Summary: division by zero in #if Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aldot at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36279