why mixin template can not inclulde statement;

learnfirst1 learnfirst1 at gmail.com
Fri Aug 10 13:25:23 UTC 2018


On Friday, 10 August 2018 at 13:17:13 UTC, learnfirst1 wrote:
> this work,  it report no error but give  a link problem.  (this 
> could be a bug ?)

mixin template test(A...){
         __gshared int a = A[0];
         pragma(inline, true) // remove this will work
         static extern(C) int test(){
                 a++;
                 return 0;
         }
         int dummy = test();
}

import core.stdc.stdio;
extern(C) void main(){
     mixin test!1;
     printf("a=%d\n", a);
}

-----------------------
Undefined symbols for architecture x86_64:
   "__D4test4mainUZ8__mixin1QvUNbNiZi", referenced from:
       _main in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: linker exited with status 1


More information about the Digitalmars-d-learn mailing list