Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site datagen.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!hao!seismo!cmcl2!rocky2!datagen!boykin From: boykin@datagen.UUCP Newsgroups: net.lang.c Subject: Declarations and defaulting in C Message-ID: <74@datagen.UUCP> Date: Wed, 4-Jul-84 10:43:36 EDT Article-I.D.: datagen.74 Posted: Wed Jul 4 10:43:36 1984 Date-Received: Sun, 8-Jul-84 00:16:23 EDT Organization: Data General Distributed Systems, Westborough, MA Lines: 42 RE: Hans Albertson's question about declarations and defaults in C, the following, taken from both K&R and the ANSI draft standards document is legal: a; int b[10]; c = 4; main() { ... } In call cases the declarations are of type 'int' and storage class 'extern' i.e. global variables. Personally I think the declarations of both 'a' and 'c' are terrible programming practice, but it IS legal. As Hans said in his note, K&R allows defaults for both type-declaration and storage class. After those two, there isn't much left to a declaration! As also pointed out, how do you tell the difference between the declaration of 'c' and an assignment to 'c' if this is within a function body? Answer, you can't. Hence this type of declaration is only allowable outside the scope of a function. The ANSI committee has ruled that this type of declaration has been and will continue to be legal even though none of the members of the committee like that type of declaration. The point is is that taking it out would break some user code. One of the chief concerns of the ANSI committee is that we never break user code, even if we don't like the 'cracks' in the language that that code takes advantage of. I hope that clears up the question(s). Joe Boykin Member, ANSI Committee X3J11 Data General Corp. Distributed Systems Group (allegra, ihnp4)!datagen!boykin