This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: FILE *foo = stderr; ==>`initializer element is not constant'
- From: Ian Lance Taylor <ian at airs dot com>
- To: Richie Baldwin <baldwinr at monolithss dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 28 Jan 2005 10:49:21 -0500
- Subject: Re: FILE *foo = stderr; ==>`initializer element is not constant'
- References: <41FA5669.8010306@monolithss.com>
Richie Baldwin <baldwinr@monolithss.com> writes:
> When trying to compile a c file using stderr, I have the declaration:
> FILE *foo = stderr;
> and it keeps giving me "Initializer element is not constant". I was
> wondering what could be done to preven this error from happening.
> I'm not sure if this is incorrect code or what, but any help would be
> appreciated.
>
> The file is a short one, it is:
> #include <stdio.h>
> FILE *foo = stderr;
>
> and it gives me the error on line 2.
>
> Any assistance that you all could provide would be greatly appreciated.
> Richard Baldwin.
This is an issue with the system library, not with the compiler. The
<stdio.h> file provided by the system library is providing a
definition of stderr which is not a constant. This is permitted by
the C standard, so your program is not highly portable. You neglected
to see which system you are using, so it is difficult to say anything
more precise.
Ian