www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/10/20/23:23:49

Date: Wed, 20 Oct 1999 23:51:45 -0300 (ADT)
From: Peter Cordes <peter AT Cordes DOT Phys DOT Dal DOT Ca>
To: pgcc AT delorie DOT com
Subject: Re: non constant initializers
In-Reply-To: <380E211A.BCAC8E1C@keycomm.it>
Message-ID: <Pine.LNX.4.10.9910202343450.9253-100000@Cordes.Phys.Dal.Ca>
MIME-Version: 1.0
Reply-To: pgcc AT delorie DOT com
X-Mailing-List: pgcc AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

 This is probably a glibc thing, not a pgcc thing.  This was happening to
me on RH6.0, with egcs and glibc 2.1.  The reason is that stdout is an
extern FILE* with glibc 2.1, rather than a know index in an array. (note
that the array address is fixed at load time, while stdout (under glibc
2.1) could be assigned to.))  Actually, it was possible to change stdout
before, except that you were always accessing it through an index into a
known array.  (_iob or something, IIRC).

 Maybe it would be possible to have the compiler and linker conspire to
initialize outfile to stdout, but this might be impossible, because it
would still have to be possible to change outfile without changing stdout,
and vice-versa.  (i.e. outfile _can't_ be an alias for stdout.)

 (and yeah, stdio.h is different between your two systems.  Note that
stdio.h is part of the C library, which is separate from the compiler.)

#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter AT cordes DOT phys. , dal.ca)

On Wed, 20 Oct 1999, leopoldo cerbaro wrote:

> Hi,
> I don't understand why the pgcc (under stampede) gives the error "non-constant
> initializer"
> with the code below, while gcc and egcc (under debian) don't give it.
> Is there some switch that one can apply?
> Are the files stdio.h different?
> --------
> #include <stdio.h>
> 
> FILE *outfile = stdout;
> 
> int main (int argc, char *argv[]) {
>    int x = 10;
>    fprintf(outfile, "%d", x);
>    return 0;
> }
> -------
> The offending line is FILE ...
> Note that if it is after main all goes well
> Many thanks
> PLEASE ANSWER TO MY ADDRESS, 'CAUSE I'M NOT IN THE MAILING LIST
> Leopoldo Cerbaro
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019