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


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

Re: Using sizeof in the preprocessor

From Pete Becker <pete@versatilecoding.com>
Organization Roundhouse Consulting, Ltd.
Newsgroups comp.lang.c++
Date 2011-05-21 10:37 -0400
Message-ID <2011052110370061214-pete@versatilecodingcom> (permalink)
References <4dd7bfa5$0$7624$9b4e6d93@newsspool1.arcor-online.net> <ir8h1q$f2o$1@dont-email.me>
Subject Re: Using sizeof in the preprocessor

Show all headers | View raw


On 2011-05-21 10:08:58 -0400, Huibert Bol said:

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

Good point.

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