On Fri, Oct 23, 2009 at 09:58:55PM +0800, Zhang Lin wrote:
> 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.

You are wrong.  The C/C++ standards actually require it to be
constant-expression, ( == 0) is not a valid constant expression.
See http://gcc.gnu.org/PR36320 for details.

> This macro is accepted by VC7.1 and Sun Studio 12.

That doesn't mean this code is not buggy.
Just use
#else
#if ...
...
#endif
instead of
#elif ...
...

        Jakub

Reply via email to