This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Was:Re: possible bug? Workaround ??? Please
- To: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Subject: Re: Was:Re: possible bug? Workaround ??? Please
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Mon, 08 Nov 1999 15:16:27 +0100
- Cc: cej at CEJCHAN dot gli dot cas dot cz,gcc-bugs at gcc dot gnu dot org
- References: <cej@CEJCHAN.gli.cas.cz's message of "Mon, 08 Nov 1999 12:23:22 +0000"><cej-991108122322.A0B25569@CEJCHAN.gli.cas.cz>
At 15:10 08.11.99 , Alexandre Oliva wrote:
>On Nov 8, 1999, cej@CEJCHAN.gli.cas.cz wrote:
>
> > Please, can you give me a hint how to modify the code to workaround this?
>
>You must initialize the variable within main(), or in a function
>called from it. Another option is to use, instead of a global
>variable, a global function like this:
>
>inline FILE **ErrorFile_func() {
> static int initialized = 0;
> static FILE *ErrorFile;
> if (!initialized) {
> ErrorFile = stdout;
> initialized = 1;
> }
> return &ErrorFile;
>}
>#define ErrorFile (*(ErrorFile_func()))
Or use the gcc constructor attribute:
static FILE *file ;
static void file_construct (void) __attribute__((constructor));
static void file_construct (void) { file = stdin; }
Franz.