...
Code Block | ||||
---|---|---|---|---|
| ||||
int i1 = 10; /* Definition, external linkage */ static int i2 = 20; /* Definition, internal linkage */ extern int i3 = 30; /* Definition, external linkage */ int i4; /* Tentative definition, external linkage */ static int i5; /* Tentative definition, internal linkage */ int i1; /* Valid tentative definition */ int i2; /* Not valid, linkage disagreement with previous */ int i3; /* Valid tentative definition */ int i4; /* Valid tentative definition */ int i5; /* Not valid, linkage disagreement with previous */ int main(void) { /* ... */ return 0; } |
Implementation Details
Microsoft Visual Studio 2013 does not warn on 2013 issues no warnings about this code, even at the highest diagnostic levels.
The The GCC compiler generates a fatal diagnostic for the conflicting definitions of i2
and i5
.
...
Code Block | ||||
---|---|---|---|---|
| ||||
int i1 = 10; /* Definition, external linkage */ static int i2 = 20; /* Definition, internal linkage */ extern int i3 = 30; /* Definition, external linkage */ int i4; /* Tentative definition, external linkage */ static int i5; /* Tentative definition, internal linkage */ int main(void) { /* ... */ return 0; } |
...