Declaring extern(C) declarations with template mixins

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 12 13:22:46 PST 2016


Is this supposed to work:

template Foo()
{
     extern(C) int printf(in char*, ...);
}

mixin Foo;

void main()
{
     printf("foo\n");
}

It fails with a linker error, undefined symbol, due to not applying C 
mangling:

Undefined symbols for architecture x86_64:
   "__D4main8__mixin76printfUxPaYi", referenced from:
       __Dmain in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list