Topic: Evaluation of #elif statement
Author: Edward Diener <eldiener@tropicsoft.invalid>
Date: Thu, 1 Sep 2011 11:05:03 -0700 (PDT) Raw View
In code such as:
#if SOME_MACRO(x)
#elif ANOTHER_MACRO(y)
#endif
is ANOTHER_MACRO expanded and evaluated for C++ correctness even when
the result of SOME_MACRO's expansion is 1.
I had always thought that ANOTHER_MACRO(y) could be anything, even
incorrect C++, as long as SOME_MACRO(x) is 1. But gcc always evaluates
ANOTHER_MACRO(y) and, if it is invalid C++, gives a compiler error, even
when SOME_MACRO(x) expands to 1.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]