Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 May 2003 22:08:54 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        sullivan@gaia.arc.nasa.gov
Cc:        arch@freebsd.org
Subject:   Re: Pardon the ignorance
Message-ID:  <20030515.220854.43850940.imp@bsdimp.com>
In-Reply-To: <Pine.OSX.4.55.0305152039360.10225@vishnu.arc.nasa.gov>
References:  <Pine.OSX.4.55.0305152039360.10225@vishnu.arc.nasa.gov>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <Pine.OSX.4.55.0305152039360.10225@vishnu.arc.nasa.gov>
            Don Sullivan <sullivan@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030515.220854.43850940.imp>