Problem with coupling shared object symbol visibility with protection

Benjamin Thaut via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 01:24:48 PST 2015


Am 31.01.2015 um 23:42 schrieb deadalnix:
> On Wednesday, 28 January 2015 at 13:48:45 UTC, Dicebot wrote:
>> Isn't that what your first proposed solution is about? That was my
>> understanding and I liked that understanding :) To be 100% clear :
>>
>> export void foo(T : int)(T x)
>> {
>>     bar(x);
>> }
>>
>> private void bar(int x) { }
>>
>> I'd expect `bar` to be exported into resulting binary so that it can
>> be linked against by any users of `foo` but for any attempt to call
>> `bar` directly from D code to fail because of protection violation. If
>> someone wants to circumvent protection by forging mangling - shooting
>> own feet is allowed.
>
> So you'd want bar to be duplicated on both sides ? This is gonna cause
> problems with di files.

No. He wants the compiler to automatically detect that the template foo 
might call bar. As a result the compiler should export bar when 
compiling the shared library so that any user of foo does not run into a 
"unresolved symbol reference" linker error. Bar would still only exist 
once: within the shared library.


More information about the Digitalmars-d mailing list