It works no problem for me. This is what I get:
$ gcc -Wall -o "Test.exe" "macro.cpp" -lstdc++ -s -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ./configure --enable-compiler=c --enable-language=c --prefix=/home/beyler/tmp/gcc-4.3.2/bin Thread model: posix gcc version 4.3.2 (GCC) COLLECT_GCC_OPTIONS='-Wall' '-o' 'Test.exe' '-s' '-v' '-mtune=generic' /home/beyler/tmp/gcc-4.3.2/bin/libexec/gcc/i686-pc-linux-gnu/4.3.2/cc1plus -quiet -v -D_GNU_SOURCE macro.cpp -quiet -dumpbase macro.cpp -mtune=generic -auxbase macro -Wall -version -o /tmp/ccx2HphX.s ignoring nonexistent directory "/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2 /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2/i686-pc-linux-gnu /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2/backward /usr/local/include /home/beyler/tmp/gcc-4.3.2/bin/include /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/include /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/include-fixed /usr/include End of search list. GNU C++ (GCC) version 4.3.2 (i686-pc-linux-gnu) compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.2. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 80f643acb5e6c86441cd11d3ee5d089a COLLECT_GCC_OPTIONS='-Wall' '-o' 'Test.exe' '-s' '-v' '-mtune=generic' as -V -Qy -o /tmp/cccKZT5N.o /tmp/ccx2HphX.s GNU assembler version 2.18.93 (i486-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.18.93.20081009 COMPILER_PATH=/home/beyler/tmp/gcc-4.3.2/bin/libexec/gcc/i686-pc-linux-gnu/4.3.2/:/home/beyler/tmp/gcc-4.3.2/bin/libexec/gcc/i686-pc-linux-gnu/4.3.2/:/home/beyler/tmp/gcc-4.3.2/bin/libexec/gcc/i686-pc-linux-gnu/:/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/:/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/ LIBRARY_PATH=/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/:/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-Wall' '-o' 'Test.exe' '-s' '-v' '-mtune=generic' /home/beyler/tmp/gcc-4.3.2/bin/libexec/gcc/i686-pc-linux-gnu/4.3.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o Test.exe -s /usr/lib/crt1.o /usr/lib/crti.o /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/crtbegin.o -L/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2 -L/home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/../../.. /tmp/cccKZT5N.o -lstdc++ -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/beyler/tmp/gcc-4.3.2/bin/lib/gcc/i686-pc-linux-gnu/4.3.2/crtend.o /usr/lib/crtn.o On Fri, Oct 23, 2009 at 12:35 PM, Zhang Lin <zhanglin0...@163.com> wrote: > Sorry, maybe my representation is not quite clear. > I mean that I didn't define ACE_HAS_NONSTATIC_OBJECT_MANAGER at all, so the > preprocesser should not process "#elif (ACE_HAS_NONSTATIC_OBJECT_MANAGER == > 0)", the following simple cpp can reproduce the problem. > > Test.cpp > ========== > #if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) > # define ACE_HAS_NONSTATIC_OBJECT_MANAGER > #elif (ACE_HAS_NONSTATIC_OBJECT_MANAGER == 0) > # undef ACE_HAS_NONSTATIC_OBJECT_MANAGER > #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ > > int main(int argc, char *argv[]) > { > return 0; > } > ========== > > the compile command is: > gcc -Wall -o "Test.exe" "Test.cpp" -lstdc++ -s > > and the error message is: > Test.cpp:3:41: error: operator '==' has no left operand > > > ----- Original Message ----- > From: "John Graham" <johngavingra...@googlemail.com> > To: <gcc@gcc.gnu.org> > Sent: Friday, October 23, 2009 10:03 PM > Subject: Re: Why does GCC Preprocessor NOT support such macro? > > >> 2009/10/23 Zhang Lin <zhanglin0...@163.com>: >> > Hello, >> > I have encountered an issue when building ACE with MinGW and GCC 4.4.1 >> > The following macro was not accepted by the preprocessor and it reported >> > such an error: "error: operator '==' has no left operand". >> > >> > #if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) >> > # define ACE_HAS_NONSTATIC_OBJECT_MANAGER >> > #elif (ACE_HAS_NONSTATIC_OBJECT_MANAGER == 0) >> > # undef ACE_HAS_NONSTATIC_OBJECT_MANAGER >> > #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ >> > >> > As I think, since ACE_HAS_NONSTATIC_OBJECT_MANAGER isn't defined, the >> > #elif branch should not be processed. >> > This macro is accepted by VC7.1 and Sun Studio 12. >> > >> > Thanks. >> > >> > Best Regards, >> > Lin Zhang >> > 2009-10-23 >> >> You'll get this error if ACE_HAS_NONSTATIC_OBJECT_MANAGER is defined, >> but has a null value - i.e. if somewhere before it was: >> >> #define ACE_HAS_NONSTATIC_OBJECT_MANAGER >> >> and not: >> >> #define ACE_HAS_NONSTATIC_OBJECT_MANAGER 1 >> >> (for example) >> >> I'm not sure if there's a way to test for a macro being null, but if >> you change your previous declarations to defining it so something >> instead of nothing, everything should be dandy. >> >> John G >>