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!news2.arglkargh.de!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" From: Johannes Schaub Reply-To: schaub.johannes-at-googlemail.com Date: Sat, 21 May 2011 22:19:41 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: Using sizeof in the preprocessor Newsgroups: comp.lang.c++ References: <4dd7bfa5$0$7624$9b4e6d93-at-newsspool1.arcor-online.net> Followup-To: comp.lang.c++ MIME-Version: 1.0 Lines: 22 Message-ID: <4dd81e48$0$6557$9b4e6d93-at-newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 21 May 2011 22:19:21 CEST NNTP-Posting-Host: 070ace45.newsspool4.arcor-online.net X-Trace: DXC=LaG_-at-aL\=mM74okIm;?DS-at-4IUKRM4XCEm1:ZIQbMX-Complaints-To: usenet-abuse-at-arcor.de Xref: panix comp.lang.c++:1085131
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. > > Can anybody please explain this? Is it a compiler bug? Thanks to all!
I want to emphasize that I do *not* intent to troll. I wanted to raise a common issue and put people in alert mode when they see such code and don't get a compiler error.
See http://chat.stackoverflow.com/transcript/message/752965#752965 and the following rage of "FredNurk" for the discussion and why I need to defend this question like that.
-- end of forwarded message --
|
|