Mail Archives: djgpp/1999/03/25/17:32:27
Johan Henriksson wrote:
>
> from Johan Henriksson, Sweden HTTP://come.to/jhewok |
> Primary mail: johan DOT he AT telia DOT com #UIN 12035895
> Second: jhe75 AT hotmail DOT com Third: johan_he AT yahoo DOT com
> Leadprogrammer and FX-specialist at Real software
> http://come.to/real_software
> *************************************************************************
> -----Original Message-----
> From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
> Newsgroups: comp.os.msdos.djgpp
> To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
> Date: Wednesday, March 24, 1999 6:48 PM
> Subject: Re: Preprocessor hates sizeof
>
> >In article <Pine DOT GSO DOT 3 DOT 96 DOT 990324144841 DOT 28874A-100000 AT delta DOT ds2 DOT pg DOT gda DOT pl>
> you wrote:
> >> Hi
> >
> >> I wonder why the following line does not compile and how to make it work:
> >
> >> #if sizeof(long int)==sizeof(int)
>
> How do you think that would work!? Of course, a long int != int. Or?
No. All the standard guarantees is that sizeof(long int) >=
sizeof(int). They can be equivalent, and in DJGPP, are.
The reason it doesn't work is that `sizeof' is parsed by the compiler
pass, not the preprocessor. (The preprocessor by tradition is
target-independent.) So the preprocessor does not know what
sizeof(type) equals.
You will have to do the test at run time (actually, a good compiler like
GCC should optimize away the test and remove the dead code), or else run
an auxilary program which does the test and use its result in a #define
somewhere.
> >
> >> (Borland likes it)
> >
> >Preprocessors are *not* allowed to like that line. Borland is
> >violating the definition of C if it accepts that line and does what
> >you think it should.
> >
> >So Borland is in error, here, not DJGPP.
Well... one could call it an extension. Heck, `inline' is invalid C,
but GCC allows it (though, I admit, not with -ansi).
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -