www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22974] New: importC: D name mangling applied to extern

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

          Issue ID: 22974
           Summary: importC: D name mangling applied to extern variable
                    inside function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

// a.c
int x;

// b.c
int main()
{ 
        extern int x;
        x = 1;
        return 0;
}

compile: dmd a.c b.c

/usr/bin/ld: a.o: in function `main':
b.c:(.text.main[main]+0x3): undefined reference to `_D1b4mainUY1xi'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

--
Apr 02 2022