Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site cbneb.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!cbosgd!cbscc!cbneb!adm
From: adm@cbneb.UUCP
Newsgroups: net.lang.c
Subject: Re: Re: C compiler for pdp-11 under RSX - (nf)
Message-ID: <898@cbneb.UUCP>
Date: Tue, 12-Jun-84 09:22:16 EDT
Article-I.D.: cbneb.898
Posted: Tue Jun 12 09:22:16 1984
Date-Received: Wed, 13-Jun-84 02:23:01 EDT
Sender: adm@cbneb.UUCP
Organization: AT&T Bell Laboratories, Columbus, OHIO
Lines: 37

#R:allegra:-252500:cbnap:16200003:000:953
cbnap!whp    Jun 12 09:09:00 1984

>> Is the following legal?
>> extern int foo;
>> ...
>> int foo;

Its not only legal, but required in some cases.  I once wrote a bit of
C code that recognized certain keywords and for each one executed a different
routine.  This was best done by an array of structures, each element
containing the keyword (as a string) and a pointer to the appropriate
function.
The point is, to create the table, the functions had to be previously delcared.
Since the table needed to be defined at the top of the C source file,
to following syntax was needed:

extern int x(), y(), z();
struct
{
    char *keyword;
    int (*function)();
} table[] = 
{
    "word1", &x,
    "word2", &y,
    "word3", &z
};
. . . 
int x(...) {...}
int y(...) {...}
int z(...) {...}

The basic rule to remember for this type of stuff is, it is legal to
define something once, and it is legal to delcare it many times.  I
think any compiler that rejects this should be called incorrect.