============== file a.d ============
module a;
extern(C) void printf(const char*, ...) @nogc pure nothrow @trusted ;
pragma(crt_constructor) extern(C) void initProcess(){
printf("call a.m\n");
}
extern(C) int main(){
printf("main\n");
return 0;
}
================file b.d ===================
module b;
extern(C) void printf(const char*, ...) @nogc pure nothrow @trusted ;
pragma(crt_constructor) extern(C) void initProcess(){
printf("call b.m\n");
}
==================================
dmd a.d b.d -betterC
./a
call a.m
main
It should output
./a
call a.m
call b.m
main
Comment #1 by schveiguy — 2017-12-30T14:23:52Z
extern(C) functions have no mangling, so you either need to name them something different, or not use extern(C).
What is happening here is that you have 2 symbols in the table named initProcess, and the linker discards one.