From -7999505289279631575
X-Google-Thread: f78e5,508c8df5e45a47fc,start
X-Google-NewGroupId: yes
X-Google-Attributes: gid7894ca11fe,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news2.google.com!news.glorb.com!news2.arglkargh.de!news.albasani.net!.POSTED!not-for-mail
From: Edward Diener <eldiener@tropicsoft.invalid>
Newsgroups: comp.std.c++
Subject: Evaluation of #elif statement
Date: Thu,  1 Sep 2011 11:05:03 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 20
Sender: std-cpp-request@vandevoorde.com
Approved: austern@google.com
Message-ID: <j3m6qk$4lo$1@dont-email.me>
Reply-To: eldiener@tropicsoft.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-Trace: news.albasani.net SPK2Ng6AjUQ1edk9QKMMxEC4SEAYtzWnwb6pX9TSiMiBA8PUSrnf1y42Djha77VB86p0JSKk82wW2w0FXZ7WMw==
NNTP-Posting-Date: Thu, 1 Sep 2011 18:05:07 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="bJNhZIvcl4qPIaWxxieZaPrH+G3WjYyvc4YSoQ/DXnQTLQtkDmDyQS+AmxzkuEesLsEtFhrU3pviW9cX1LgqluFCOLjxKJkJx9oIOCFSOgkyY2a5wg2LMcFVRZ2hnog1"; mail-complaints-to="abuse@albasani.net"
X-Mailer: Perl5 Mail::Internet v2.05
X-Submission-Address: std-cpp-submit@vandevoorde.com
Cancel-Lock: sha1:6QdgBnLc/Hy5YBbEkJ4sk96oVXs=
X-Original-Date: Wed, 31 Aug 2011 16:49:55 -0400
Xref: g2news2.google.com comp.std.c++:3412

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                      ]


