Include files

Bob Larson blarson at skat.usc.edu
Mon Jan 30 17:21:14 AEST 1989


In article <7360 at csli.STANFORD.EDU> gandalf at csli.stanford.edu (Juergen Wagner) writes:
>o  If you look at standard header files like <dbm.h>, there are lines
>	char    pagbuf[PBLKSIZ];
>	char    dirbuf[DBLKSIZ];
>   i.e. variable declarations. If you include the header file twice (and
>   function-local), you will end up with two copies of the (supposedly)
>   shared state variables.

If you include this in two separatly compiled modules, it wouldn't
work either.  It looks like whoever wrote dbm.h forgot that C uses
that def/ref linking model on some systems.  (The declarations MUST be
declared extern in all but one place.)  Adding the extern keyword to
these declarations might be adiquate for some systems, but the
variables realy should be declared without the extern keyword in
exactly one place.  Since dbm.h wasn't written with portibility in
mind, it isn't a good example.

-- 
Bob Larson	Arpa: Blarson at Ecla.Usc.Edu	blarson at skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%ais1 at ecla.usc.edu
			oberon!ais1!info-prime-request



More information about the Comp.lang.c mailing list