Path: utzoo!attcan!uunet!husc6!mailrus!ames!ll-xn!mit-eddie!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: Initialization in #include files Message-ID: <1173@mcgill-vision.UUCP> Date: 20 Jun 88 08:50:21 GMT References: <28400001@ntvax> <6104@sigi.Colorado.EDU> <2955@ihlpe.ATT.COM> <8046@brl-smoke.ARPA> Organization: McGill University, Montreal Lines: 98 In article <8046@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <5776@chinet.UUCP> les@chinet.UUCP (Leslie Mikesell) writes: >> But the variables are very likely to be used in every source file, > I do hope you people know better than to design software with lots of > pathological inter-module connections like this. Let's pick an example. I wrote a dvi-to-printer program for our printers here. Here's the list of global variables (the .h file which every file includes). What would you recommend I do with each one? All of them hold stuff which is conceptually global, ie, which should be available to any module which cares to refer to it. [#include blather (type definitions, eg) deleted] extern PAGENO veryfirst; extern PAGENO verylast; These are the lowest and highest possible page numbers. PAGENO is a non-simple type, so these are initialized data rather than #defines. Under ANSI they would be declared const. extern char *inclexcl[MAX_INCL_EXCL]; extern int n_inclexcl; extern PAGENO ie_pgs[MAX_INCL_EXCL][2]; extern int default_is_excl; extern int is_excl[MAX_INCL_EXCL]; These variables describe the results of parsing the command-line options to select what pages of the dvi file to print. extern int debugging; This variable turns on debugging information from various modules. extern char dvifile[256]; extern FILE *dvif; Variables describing the dvi file: name and FILE pointer. extern SIXVALUES *stack; #define h stack->H #define v stack->V #define hh stack->HH #define vv stack->VV #define w stack->W #define x stack->X #define y stack->Y #define z stack->Z The stack of positions (see the dvi file format documentation). extern FONT *fonts; extern FONT *curfont; The list of all fonts and the current font. extern int numerator; extern int denominator; extern double trueconv; extern int mag; extern double conv; These hold global information obtained from the dvi file, things like conversion ratios between dvi file units and pixels. extern int dvilength; extern int postamble; extern int firstbackpointer; Stuff to help find the dvi file administrivia. extern int maxh; extern int maxv; Maximum values of h and v (see the dvi format documentation). extern int npages; extern long int *pg_begins; Number of pages and locations at which they begin in the dvi file. extern int startloc; Set but never used (historical artifact). extern PRINTER *printer; Pointer through which printer-specific routines are accessed. extern int Fflag; extern int Xflag; Two command-line flags, to be used by the printer routines. extern int nfontdirs; extern char **fontdirs; extern int maxfdlen; The results of parsing the path for font files. extern char defaultfontpath[]; extern char fontpath_env[]; Initialized strings for the font file path. extern int missingfonts; Indication of whether there were any fonts for which the bitmap files could not be located. der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu