Lattice/UNIX incompatibility
g-frank at gumby.UUCP
g-frank at gumby.UUCP
Wed Jan 2 05:48:32 AEST 1985
> >> 3. Every declaration of an external variable but
> >> one must say 'extern'.
>
> > For any linker that supports FORTRAN, this restriction shows a lack of
> > imagination on the part of the c compiler writers. Don't get me started
> > on this; it's a favorite flame.
>
> Or, perhaps, just a desire for C to work correctly. K & R specify this
> behavior and doing otherwise invites nonportable code.
> --
I realize that it's normal under UNIX to be able to declare the same
variable multiple times and count on the linker to resolve it to a single
location. I also realize that it's convenient to do this because one might
want to include such a declaration in a header file, to be read by all
compilands of a particular program.
Nonetheless, my common sense rebels. A particular variable "belongs" to a
particular module, and is "external" to all other modules. Real languages
enforce this restriction in a meaningful way (as does C++, I believe).
There IS semantic meaning to where a variable is declared.
More information about the Comp.lang.c
mailing list