WebAssembly _start or crt_constructor not get called.

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


On Friday, 10 August 2018 at 08:45:07 UTC, learnfirst1 wrote:
>
> extern(C) {
> 	__gshared int counter = 1;
> 	pragma(crt_constructor) void ginit(){
> 		counter++;
> 	}
> 	
> 	int getCounter(){
> 		return counter;
> 	}
>
> 	void _start() {
> 		counter++;
> 	}
> }
> ----------------------
>
> build with ldc2 -mtriple=wasm32-unknown-unknown-wasm -betterC 
> test.d -link-internally
>
> I expect the getCounter return 3, but it return 0, is this a 
> bug  ?

I write wrong, it return 1 not 0 on browser.


More information about the digitalmars-d-ldc mailing list