Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pur-ee.UUCP Path: utzoo!watmath!clyde!floyd!harpo!ulysses!mhuxl!ihnp4!inuxc!pur-ee!ecn-ee!ks From: ks@ecn-ee.UUCP Newsgroups: net.lang.c Subject: Re: extern declaration inconsistency - (nf) Message-ID: <1779@pur-ee.UUCP> Date: Thu, 5-Apr-84 08:19:21 EST Article-I.D.: pur-ee.1779 Posted: Thu Apr 5 08:19:21 1984 Date-Received: Sat, 7-Apr-84 03:28:35 EST Sender: notes@pur-ee.UUCP Organization: Electrical Engineering Department , Purdue University Lines: 35 #R:mit-eddi:-153800:ecn-ee:13100011:000:1241 ecn-ee!ks Apr 4 15:58:00 1984 There is an important distinction between the following: extern char ch[]; extern char *ch; ch[] indicates that you have reserved space elswhere for some number of characters and you can use ch as the address of the first reserved space. *ch indicates that you reserved space for a pointer to some characters which may or may not contain a valid value such that it points to some real space that is holding some characters. In the first case, ch is a "constant", and in the second case, ch is a variable. The confusion persists because when either form of ch is passed to a function as a parameter, it is passed by value. (The value of an array is the address of it's first element.) All function parameters can be modified as if they were automatic variables, so both forms are equivalent only for function parameter declarations. In my opinion, this is a very elegant way of doing things, even if it is confusing at first. The REAL problem is that many C loaders do not flag the extern declaration as an error. They just load incorrect code. So, the moral of the story is: >>>> USE LINT <<<< The compiler is not meant to check for every little inconsistency. That is why lint is around. Kirk Smith Purdue EE