Pardon the ignorance

M. Warner Losh imp at bsdimp.com
Thu May 15 21:09:32 PDT 2003


In message: <Pine.OSX.4.55.0305152039360.10225 at vishnu.arc.nasa.gov>
            Don Sullivan <sullivan at gaia.arc.nasa.gov> writes:
: 
: In the change to stdio.h in FreeBSD 4.8, you say:
: "std{in,out,err} are no longer compile time constants."
: 
: Please pardon my incredible ignorance, but what does that mean ?
: Can you please point me to a reference ?
: 
: FILE *def_thing = stdout;
: 
: no longer works.
: apparently, it shouldn't. why ?

>From the C-90 standard, section 7.19 paragraph #3

Because 'stdout' isn't guaranteed to be a compile time constant:
               stderr
               stdin
               stdout

       which are expressions of type ``pointer to FILE'' that point
       to the  FILE  objects  associated,  respectively,  with  the
       standard error, input, and output streams.

Since they are not 'constant expressions ...' it means that they
aren't guaranteed to evaludate to a constant at compile time.  FILE
*def_thing = stdout; requires that stdout be a compile time constant
when it is at the top level.  Traditionally, it has been a compile
time constant on some implementations, so the above would work.
However, there are issues with making it a compile time constant and
still being able to make the size of FILE larger over the course of
time.

Warner



More information about the freebsd-arch mailing list