This is the mail archive of the gcc-bugs@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]

Re: Was:Re: possible bug? Workaround ??? Please


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.


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