Non-constant initializers
Kaz Kylheku
kaz@cafe.net
Wed Apr 22 08:38:00 GMT 1998
On Tuesday, April 21, 1998 5:14 PM, Ross Alexander
[SMTP:r.alexander@auckland.ac.nz] wrote:
> It seems that code like
>
> #include <stdio.h>
>
> FILE *f = stdin;
>
> int main()
> {
> ..
> }
>
> fail because of non-constant initializer. This did not happen before.
> Is there any way to tell egcs-980321 how to handle this, or should I
> upgrade.
You need to upgrade your program to valid C. Nowhere in the standard
is it required that ``stdin'' be a constant expression; hence your
program is ill formed.
For example, stdin could quite naturally be be a static object
declared as
extern FILE *stdin;
after which stdin is anything but a constant expression.
C programs which depend on stdin or stdout to expand to
address constants are simply not portable.
More information about the Gcc
mailing list