Date: Sun, 24 Oct 1999 13:55:02 +0200 From: Marc Lehmann To: pgcc AT delorie DOT com Subject: Re: non constant initializers Message-ID: <19991024135502.B767@cerebro.laendle> Mail-Followup-To: pgcc AT delorie DOT com References: <19991023215020 DOT A5053 AT cerebro DOT laendle> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: ; from Peter Cordes on Sat, Oct 23, 1999 at 10:02:40PM -0300 X-Operating-System: Linux version 2.2.12 (root AT cerebro) (gcc version 2.95.1 19990816 (release)) Sender: Marc Lehmann Reply-To: pgcc AT delorie DOT com X-Mailing-List: pgcc AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sat, Oct 23, 1999 at 10:02:40PM -0300, Peter Cordes wrote: > Since C doesn't do it, what is a good way to have a > static FILE *errfile; > in a module of a bigger program? There isn't (in C). with gnu c you could use constructors. > Is there a solutions which doesn't > require an initialization routine have to be called from main() to init it > (if none is otherwise required)? One solution is to have static FILE > *errfile = NULL and check for null on entry to every function which uses > it. If null, then set it to stderr. This is anoying, though. At least This is a bit less annoying (requiring fewer source changes): #define errfile (errfile?errfile:stderr) > overhead is not a big concern, since this is just for error logging. Yeah, C does have some problems with modularization. In the old times, however, nobody had a problem with calling 555+ initialization routines.. -- -----==- | ----==-- _ | ---==---(_)__ __ ____ __ Marc Lehmann +-- --==---/ / _ \/ // /\ \/ / pcg AT opengroup DOT org |e| -=====/_/_//_/\_,_/ /_/\_\ XX11-RIPE --+ The choice of a GNU generation | |