DIP45: fixing the dllimport/dllexport issue

Benjamin Thaut code at benjamin-thaut.de
Thu Aug 29 13:17:58 PDT 2013


Am 29.08.2013 22:04, schrieb Martin Nowak:
>
> So the alias trick would only work for functions.

yes

> For data the _imp_* symbol would need to be a pointer to the data?

yes

> How about LTO, when statically linking it should be possible to optimize
> away the indirection.

Rainer Schuetze stated that some linkers are capable of doing this 
optimizations. But I don't know aynthing further about this topic.

>
> module libA;
> export int var;
> int* _imp_var = &var; // created by compiler
>
> module foo;
> import libA;
>
> void bar()
> {
>      auto val = var; // creates val = *_imp_var;
> }
>

Yes that would work. Still there must be a reason why microsoft doesn't 
do stuff like that in their C++ toolchain. Its certanly going to cost 
performance.


More information about the Digitalmars-d mailing list