delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/12/04/21:07:50

From: sopchak AT aoainc DOT com (Jim Sopchak)
Subject: Re: BUG: stdin not a constant
4 Dec 1997 21:07:50 -0800 :
Message-ID: <348734F0.4C28.cygnus.gnu-win32@aoainc.com>
References: <199712040048 DOT LAA26596 AT rimmer DOT cs DOT mu DOT OZ DOT AU>
Reply-To: sopchak AT aoainc DOT com
Mime-Version: 1.0
To: Fergus Henderson <fjh AT cs DOT mu DOT OZ DOT AU>
Cc: gnu-win32 AT cygnus DOT com, petdr AT students DOT cs DOT mu DOT oz DOT au

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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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