www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22259] New: importC: Redundant declarations of extern

https://issues.dlang.org/show_bug.cgi?id=22259

          Issue ID: 22259
           Summary: importC: Redundant declarations of extern variables
                    fail to compile.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

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.

--
Aug 31