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


Groups > comp.lang.c++ > #5259

Re: Using sizeof in the preprocessor

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Sat, 21 May 2011 08:42:08 -0500
From Pete Becker <pete@versatilecoding.com>
Organization Roundhouse Consulting, Ltd.
Newsgroups comp.lang.c++
Date Sat, 21 May 2011 09:42:08 -0400
Message-ID <2011052109420832334-pete@versatilecodingcom> (permalink)
References <4dd7bfa5$0$7624$9b4e6d93@newsspool1.arcor-online.net>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Subject Re: Using sizeof in the preprocessor
User-Agent Unison/2.1.4
Lines 24
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-Fzru1SJoBPw/1jhdSkdE2BDxGAmmBCPE5oRZrFoz00Te/rAYkrarKg8NrPmw/9NdTlIVgrgS2JwDqrD!L0Nq5NhLmA5x0WqY1cBbKEdQSUJ08UUpArN43Jcq2UeLx4jqKK23sW+KG1sgHoVLeup96qQk
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1856
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:5259

Show key headers only | View raw


On 2011-05-21 09:35:53 -0400, Johannes Schaub said:

> 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!

Bug or extension. The preprocessor does text manipulation; it doesn't 
know anything about types (although it has its own set of rules for 
arithmetic).

-- 
  Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The 
Standard C++ Library Extensions: a Tutorial and Reference 
(www.petebecker.com/tr1book)

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using sizeof in the preprocessor Johannes Schaub <schaub.johannes@googlemail.com> - 2011-05-21 15:35 +0200
  Re: Using sizeof in the preprocessor Pete Becker <pete@versatilecoding.com> - 2011-05-21 09:42 -0400
  Re: Using sizeof in the preprocessor Huibert Bol <huibert.bol@quicknet.nl> - 2011-05-21 16:08 +0200
    Re: Using sizeof in the preprocessor Pete Becker <pete@versatilecoding.com> - 2011-05-21 10:37 -0400
    Re: Using sizeof in the preprocessor Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 18:51 +0000
      Re: Using sizeof in the preprocessor Huibert Bol <huibert.bol@quicknet.nl> - 2011-05-21 21:52 +0200
      Re: Using sizeof in the preprocessor Johannes Schaub <schaub.johannes@googlemail.com> - 2011-05-21 21:54 +0200
      Re: Using sizeof in the preprocessor Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-05-21 21:54 +0200
        Re: Using sizeof in the preprocessor Juha Nieminen <nospam@thanks.invalid> - 2011-05-22 06:02 +0000
  Re: Using sizeof in the preprocessor Johannes Schaub <schaub.johannes@googlemail.com> - 2011-05-21 22:19 +0200

csiph-web