[Issue 23011] New: importC: asm label to set symbol name doesn't work with externs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 13 16:33:44 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23011
Issue ID: 23011
Summary: importC: asm label to set symbol name doesn't work
with externs
Product: D
Version: D2
Hardware: All
OS: Linux
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: duser at neet.fi
CC: duser at neet.fi
runnable example (that currently fails):
extern char **myenviron asm("environ");
int myprintf(char *, ...) asm("printf");
int main()
{
void *p = &myenviron;
myprintf("%p\n", p);
return 0;
}
works with gcc/clang, gives a link error with dmd
/usr/bin/ld: test.o: in function `main':
test.c:(.text.main[main]+0x7): undefined reference to `myenviron'
/usr/bin/ld: test.c:(.text.main[main]+0x18): undefined reference to `myprintf'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
it should be linking with the names given in asm()
--
More information about the Digitalmars-d-bugs
mailing list