extern

Stephen Clamage steve at taumet.com
Sat Jul 7 03:20:05 AEST 1990


In article <1990Jul5.044045.1534 at acc.stolaf.edu> hannum at haydn.psu.edu (Charles Hannum) writes:
>... why didn't ANSI specify that initializers on externs should be
>ignored?  This would be really keen for the former type of definitions.

The problem here is that the keyword "extern" can mean either "external"
(defined elsewhere) or "global" (defined here) depending on context.  To
simplify a bit, for data objects it means external if there is no initializer,
global if there is.  For functions, the external/global meaning is determined
solely by the presence of a function body.

I don't think that anyone will argue that this is a wonderful convention,
but the ANSI committee inherited it from long C practice.  Introducing
extern and global keywords as used in other languages (notably assembler)
would have had the advantage of precision, but would have broken many
(most?) existing programs.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list