is this a bug ? mixin template static function missing!

learnfirst1 learnfirst1 at gmail.com
Fri Aug 10 08:31:21 UTC 2018


#!/usr/bin/env rdmd
import core.stdc.stdio;

template G(size_t line = __LINE__, A...){
	int i = 3;
	static extern(C) pragma(crt_constructor) void init2(){
		printf("init: %d\n", line);
	}
}

pragma(crt_constructor) extern(C) void init1(){
       printf("init from global\n");
}

struct A {
	mixin G!();
}

extern(C) void main(){
	mixin G!() g;
	printf("g.i=%d\n", g.i);
	g.init2(); // remove this can build, but g.init2 not get called!
}

-----------------

build error:
Undefined symbols for architecture x86_64: 
"__D4test4mainUZ1g5init2UNbNiZv", referenced from:





More information about the Digitalmars-d-learn mailing list