On Fri, Jan 10, 2020 at 02:07:53PM -0500, Dan Cross wrote:
My colleague was particularly surprised that this seemed required: even at
this early stage, the `extern` keyword was present, so why bother with this
behavior? Why not, instead, make it a link-time error? Please note that if
two source files have initializers for these variables, then one gets a
multiple-definition link error. The 1988 ANSI standard made this an error
(or at least undefined behavior) but the functionality persists; GCC is
changing its default to prohibit it (my colleague works on clang).
This behaviour differed between platforms, unix using the common approach,
and some other platforms simplying making it a (non common) symbol in the bss.
Having learnt C in its pre-ANSI form on unix, I then ran in to this behaviour
on DOS C compilers. None of which (that I came across) providing the 'common'
behaviour.
DF