Mail Archives: pgcc/1999/10/24/19:18:25
On Sat, Oct 23, 1999 at 10:02:40PM -0300, Peter Cordes <peter AT Cordes DOT Phys DOT Dal DOT Ca> 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 |
|
- Raw text -