Bug 22259 – importC: Redundant declarations of extern variables fail to compile.
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-01T00:58:21Z
Last change time
2021-09-24T19:22:32Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
dave287091
Comments
Comment #0 by dave287091 — 2021-09-01T00:58:21Z
The following c program fails to compile.
// extern.c
extern char something;
extern char something;
int main(void){
return 0;
}
The following error is reported:
extern.c(2): Error: variable `extern.something` conflicts with variable `extern.something` at extern.c(1)
Redundant declarations of extern variables is legal in C.
On macOS, extern char* suboptarg is declared in both unistd.h and stdlib.h. Thus if you have a header that includes both (like Python.h), the program fails to compile.