delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/25/10:50:54

Newsgroups: comp.os.msdos.djgpp
From: fredex AT fcshome DOT stoneham DOT ma DOT us (fred smith)
Subject: Re: Preprocessor hates sizeof
X-Newsreader: TIN [version 1.2 PL2]
Organization: None!
Message-ID: <F94qz3.54A@fcshome.stoneham.ma.us>
References: <Pine DOT GSO DOT 3 DOT 96 DOT 990324144841 DOT 28874A-100000 AT delta DOT ds2 DOT pg DOT gda DOT pl>
Date: Thu, 25 Mar 1999 02:59:26 GMT
Lines: 25
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Wojciech Piechowski (voyt AT ds2 DOT pg DOT gda DOT pl) wrote:
: Hi

: I wonder why the following line does not compile and how to make it work:

: #if sizeof(long int)==sizeof(int)

: (Borland likes it)

As I recall, the ANSI/ISO standard for the C language specifies that 
sizeof() is evaluated AFTER the conditional compilation directives, not
before. That being the case you cannot use this construct in any ANSI-
conforming program/compiler. 

There is a standard include named limits.h which contains information
that can be used to write some somewhat different code that will in the
end do what you want, but you can't do it in this way. Check out limits.h
and look for INT_MAX and LONG_MAX.

Fred
--
---- Fred Smith -- fredex AT fcshome DOT stoneham DOT ma DOT us -----------------------------
                       I can do all things through Christ 
                              who strengthens me.
------------------------------ Philippians 4:13 -------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019