Initialization in #include files
der Mouse
mouse at mcgill-vision.UUCP
Mon Jun 20 18:50:21 AEST 1988
In article <8046 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
> In article <5776 at chinet.UUCP> les at 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 at mcgill-vision.uucp
arpa: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.lang.c
mailing list