MESSAGE
DATE | 2011-06-11 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Using sizeof in the preprocessor
|
-- forwarded message -- Path: reader1.panix.com!panix!news.linkpendium.com!news.linkpendium.com!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Huibert Bol Newsgroups: comp.lang.c++ Subject: Re: Using sizeof in the preprocessor Date: Sat, 21 May 2011 16:08:58 +0200 Organization: A noiseless patient Spider Lines: 22 Message-ID: References: <4dd7bfa5$0$7624$9b4e6d93-at-newsspool1.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="zaorCeL+9EqcwERxopEMWA"; logging-data="15448"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1+9CdvzazOd+eyBb9m2OGlg" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:qCIzQabRX24GeK00rUmj5wr5vWk= Xref: panix comp.lang.c++:1085097
Johannes Schaub wrote:
> I have this code in my pet project > > #if sizeof -1 > 4 > #error "This doesn't work on 64bit" > #endif > > My friend was telling me that this shouldn't work because "sizeof is not > evaluated in the preprocessor". Yet the compiler accepts it and my program > works.
Identifiers in #if expressions are evaluated as zero, so the expression is equivalent to
#if 0 -1 > 4
which is never true.
-- Huibert "Okay... really not something I needed to see." --Raven -- end of forwarded message --
|
|