C compiler for pdp-11 under RSX - (nf)

adm at cbneb.UUCP adm at cbneb.UUCP
Tue Jun 12 23:22:16 AEST 1984

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
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();
    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.

More information about the Comp.lang.c mailing list