Subject: Re: BUG: stdin not a constant
From: [email-masked] (Jim Sopchak)

4 Dec 1997 21:07:50 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Fergus Henderson <[email-masked]>
Cc: [email-masked], [email-masked]

Petdr,

Having dealt with the same problem in a port before, I've found the best
way to do it (IMHO), is to quickly identify all such globals (static or
otherwise) from the compiler/linker errors and initialize them first
thing in main() before any use.  Think of it as being the same
responsibility you have when initializing member variables in a
constructor.

#include <stdio.h>

static FILE *out = (FILE *)NULL ;

void my_out_func(char *szMsg)
{
	fprintf(out, "%s", szMsg);
}

void main(void)
{
	out = stdout ;
	fprintf(out, "hello world\n");
	my_out_func("...so cold 'n cruel.\n") ;
}

Bon apetite,

Jim
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".