Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #266

Evaluation of #elif statement

From Edward Diener <eldiener@tropicsoft.invalid>
Newsgroups comp.std.c++
Subject Evaluation of #elif statement
Date 2011-09-01 11:05 -0700
Organization A noiseless patient Spider
Message-ID <j3m6qk$4lo$1@dont-email.me> (permalink)

Show all headers | View raw


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                      ]

Back to comp.std.c++ | Previous | Next | Find similar


Thread

Evaluation of #elif statement Edward Diener <eldiener@tropicsoft.invalid> - 2011-09-01 11:05 -0700

csiph-web