The static function compilation environment is the host?

sdv sdvcn at 126.com
Fri Dec 31 00:08:00 UTC 2021


this code:
```d
#!/usr/bin/env dub
/+ dub.sdl:
     buildOptions "betterC"
+/


static pl1()
{
	class tc1{

	}
	auto vtc1 = new tc1();
	
	return vtc1.mangleof;
}

enum vpl1 = {
	class tc1{

	}
	auto vtc1 = new tc1();
	
	return vtc1.mangleof;
};

pragma(msg,pl1);
pragma(msg,pl1());
pragma(msg,vpl1());


version(D_BetterC)
{
	pragma(msg,"is betterC");
	extern (C) int main(int argc, char** argv) {
		return 0;
	}
}else{
	pragma(msg,"not betterC");
	void main()
	{
	}
}

for ldc2

```
dub build --compiler=ldc2
Performing "debug" build using ldc2 for x86_64.
wasm-runtime ~master: building configuration "application"...
_D3app3pl1FZ4vtc1CQqQoFZ3tc1
_D3app3pl1FZ4vtc1CQqQoFZ3tc1
_D3app9__lambda5MFZ4vtc1CQxQvMFZ3tc1
is betterC
Linking...
test.obj : error LNK2019: unresolved external symbol 
_D3app3pl1FZ3tc17__ClassZ referenced in function 
_D3app3pl1FNaNbNfZAya
test.obj : error LNK2019: unresolved external symbol 
_d_allocclass referenced in function _D3app3pl1FNaNbNfZAya
test.obj : error LNK2001: unresolved external symbol 
_D6object6Object8toStringMFZAya
test.obj : error LNK2001: unresolved external symbol 
_D6object6Object6toHashMFNbNeZm
test.obj : error LNK2001: unresolved external symbol 
_D6object6Object5opCmpMFCQqZi
test.obj : error LNK2001: unresolved external symbol 
_D6object6Object8opEqualsMFCQtZb

```


Should the environment in which the Pl1 function is compiled be 
the host environment or the target environment?

The result is correct during compilation,

linker errors occur in betterc mode
I think static functions should use the host environment


Symbolic links should not be used after the results are obtained








More information about the Digitalmars-d mailing list