Object.factory() and exe file size bloat
Benjamin Thaut via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 23 06:15:51 PDT 2015
On Sunday, 23 August 2015 at 13:09:46 UTC, Benjamin Thaut wrote:
>
> The good news is, once I'm done with my windows DLL work the
> code can be trivialy reused to make export control the
> visibility of symbols on linux as well.
>
> Kind Regards
> Benjamin Thaut
But then you have the same problem on linux as on windows.
"Export" controls not only the symbol visibility across shared
library boundaries but also the module level visibility. E.g.
this is a problem
private void SomeImplementationDetail() { ... }
void SomeTemplateFunc(T)()
{
SomeImplementationDetail();
}
If you compile this into a shared library and all symbols are
hidden by default unless marked with export it will fail to
compile if someone tries to use it. Because the instanciated
template SomeTemplateFunc will call the SomeImplementationDetail
function which is not visible across the shared library boundary.
To fix this you would have to do:
export void SomeImplementationDetail() { ... }
void SomeTemplateFunc(T)()
{
SomeImplementationDetail();
}
But this means that users of the shared library would suddenly be
allowed to call SomeImplementationDetail.
The fix would be to make export an attribute instead of an
protection level resulting in:
private export void SomeImplementationDetail() { ... }
void SomeTemplateFunc(T)()
{
SomeImplementationDetail();
}
More information about the Digitalmars-d
mailing list