Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site mtxinu.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!hplabs!intelca!qantel!dual!unisoft!mtxinu!ed From: ed@mtxinu.UUCP (Ed Gould) Newsgroups: net.unix,net.bugs.4bsd Subject: Re: Compiler bug Message-ID: <364@mtxinu.UUCP> Date: Tue, 7-May-85 12:15:49 EDT Article-I.D.: mtxinu.364 Posted: Tue May 7 12:15:49 1985 Date-Received: Sun, 12-May-85 01:46:13 EDT References: <121@galbp.UUCP> Distribution: net Organization: mt Xinu, Berkeley, CA Lines: 40 Xref: linus net.unix:3876 net.bugs.4bsd:1211 > I noticed this idiosyncrasy with regards to our C compiler. Given the > following > > > int a; > > int a; > > > > main() > > { > > for (;;) > > ; > > } > > When compiling this, the compiler generates no error messages. Seems > to me, it should give a "redeclaration of a" error message. It does > give the error message, if the two int's are made automatic variables > (i.e., declared within main()). > > ... running 4.2BSD. The C language allows multiple definitions of *external* variables. In all (that I know of, anyway) implementations under Unix declarations made outside of a function are external - not just to the functions in that file, but to the file as well. Some AT&T compilers - specifically those on System V - complain about the construction you describe. Lots of folks have griped about that! If the declarations *within* one file aren't consistent, e.g., int a; struct { int c; int d; } a; any compiler should complain. (Of course, there is *no* checking if the declarations are in separately-compiled files!) -- Ed Gould mt Xinu, 2910 Seventh St., Berkeley, CA 94710 USA {ucbvax,decvax}!mtxinu!ed +1 415 644 0146