Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!jpl From: jpl@allegra.UUCP (John P. Linderman) Newsgroups: net.unix-wizards Subject: Re: Let ME try for a new topic... Message-ID: <2506@allegra.UUCP> Date: Sun, 3-Jun-84 15:12:51 EDT Article-I.D.: allegra.2506 Posted: Sun Jun 3 15:12:51 1984 Date-Received: Tue, 5-Jun-84 19:30:02 EDT References: <182@itm.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 55 externs and include files are two subjects guaranteed to raise my blood pressure. The decision by certain compiler purveyors that variables could be "defined" (i.e. appear without an extern) only once caused many useful programs to be uncompilable. Many of us considered that it was more important to keep software working than to satisfy some bureaucrat's concept of "clean coding". (Please spare me chapter 11, verse 2 from K&R.) We adopted the following artifice to simplify maintenance of code that included external variables in .h files. If the include file used to look like int i; char foo[] = "bar"; we would replace them with #ifdef OWNER #define EXTERN #define EXTINIT(X) = X #else #define EXTERN extern #define EXTINIT(X) #endif OWNER EXTERN int i; EXTERN char foo[] EXTINIT("bar"); In the makefile, we would then include a -DOWNER flag in exactly one cc line, usually the one for the main routine. This made it easy to get programs working again without having to duplicate headers or rewrite code. Speaking of include files, I get constant complaints from users whose code won't compile, either because they includedbut not (which stat.h requires, at least under 4.2), or because they managed to include twice. The latter problem is particularly annoying because it is so easy to fix. All include files ought to be of the form #ifndef typesdefined #define typesdefined #endif typesdefined so multiple inclusions cause no problems. I am hesitant to fix this unilaterally, because then programs that work fine here might not compile elsewhere. But it ought to be fixed, both under Berkeley and System 5. Once that fix is in for all header files, it would be possible for to do its own include of , since repeated inclusions would do no semantic damage. This proposal is microscopically harder to defend: the redundant includes might make compiles slower. I find it hard to get excited about slower compiles, but I'm willing to accept that there may be places where it is important. John P. Linderman Department of War on Morons allegra!jpl