This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FILE *foo = stderr; ==>`initializer element is not constant'


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]