Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!oberon!skat.usc.edu!blarson From: blarson@skat.usc.edu (Bob Larson) Newsgroups: comp.lang.c Subject: Re: Include files Message-ID: <15019@oberon.USC.EDU> Date: 30 Jan 89 07:21:14 GMT References: <10991@umn-cs.CS.UMN.EDU> <9526@smoke.BRL.MIL> <10995@umn-cs.CS.UMN.EDU> <7360@csli.STANFORD.EDU> Sender: news@oberon.USC.EDU Reply-To: blarson@skat.usc.edu (Bob Larson) Organization: USC AIS, Los Angeles Lines: 22 In article <7360@csli.STANFORD.EDU> gandalf@csli.stanford.edu (Juergen Wagner) writes: >o If you look at standard header files like , 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@Ecla.Usc.Edu blarson@skat.usc.edu Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson Prime mailing list: info-prime-request%ais1@ecla.usc.edu oberon!ais1!info-prime-request