J
Jean-Claude Arbaut
I have two questions:
* is it allowed to have "int c=1;" in some file and "int c;" in another,
with no other declaration or definition of c ? If I understand the standard,
the second declaration is a "tentative definition", and it implies
initialization to 0, so there should be a multiple definition error. But
with gcc (and I was told, with other compilers as well), it works without
complain.
* is it allowed to have two declarations/definitions in different files,
with different types, e.g. "int c;" "extern char c;". The standard says
"common" variables represent the same object, but I am in doubt. Other
discussions showed that declarations with different types are allowed, but
this case (int/char) was not discussed. And again gcc does not complain.
* is it allowed to have "int c=1;" in some file and "int c;" in another,
with no other declaration or definition of c ? If I understand the standard,
the second declaration is a "tentative definition", and it implies
initialization to 0, so there should be a multiple definition error. But
with gcc (and I was told, with other compilers as well), it works without
complain.
* is it allowed to have two declarations/definitions in different files,
with different types, e.g. "int c;" "extern char c;". The standard says
"common" variables represent the same object, but I am in doubt. Other
discussions showed that declarations with different types are allowed, but
this case (int/char) was not discussed. And again gcc does not complain.