On Thu, 26 Aug 2004 09:00:24 -0500, "Doug Jones"
[...re: multiple "static int XX;" at file scope...]
Section 6.9.2 (External Object Definitions) p2 and p3 say:
"A declaration of an identifier for an object that has file scope
without an initializer, and without a storage-class specifier or
with the storage-class specifier static, constitutes a tentative
definition. If a translation unit contains one or more tentative
definitions for an identifier, and the translation unit contains
no external definition for that identifier, then the behavior is
exactly as if the translation unit contains a file scope
declaration of that identifier, with the composite type as of the
end of the translation unit, with an initializer equal to 0.
"If the declaration of an identifier for an object is a tentative
definition and has internal linkage, the declared type shall not
be an incomplete type."
"static int XX:" is a declaration of an identifier for an object that
has file scope, has no initializer, and has only the storage-class
specifier "static." Furthermore, "int" is not an incomplete type. So
it is a "tentative definition." Multiple tentative definitions are
legal. The compiler is not required to complain.
The compiler is _allowed_ to complain, but it is not allowed to refuse
to compile the code. Such diagnostics are QoI issues.
If one of the definitions disagreed with another (e.g., different type
or not static), or more than one initialized the object (even if the
initializers were identical), then diagnostics would be required, and
the compiler could refuse to compile.
Do you get a diagnostic if you change the declarations to
static int XX = 0;
Change is inevitable, progress is not.