Dynamic bindings to global variables

remi thebault via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 2 11:30:42 PDT 2015


On Sunday, 2 August 2015 at 16:20:29 UTC, remi thebault wrote:
> On Sunday, 2 August 2015 at 15:38:34 UTC, Mike Parker wrote:
>> You have to declare it as a pointer, then retrieve the pointer 
>> in the same way you do the function pointers, via the system 
>> loader (GetProcAddress/dlsym).
>
> and how would you make this source compatible with the static 
> binding version?
> I guess it is not possible
>
> extern(C):
> version(Dynamic) {
>     __gshared wl_interface *wl_display_interface;
> }
> else {
>     extern __gshared wl_interface wl_display_interface;
> }
>
>
> // use case: some_func expects a pointer to wl_interface
> // the C version is using addressof operator, (as do the static 
> D bindings)
> some_func(&wl_display_interface);

I'll manage this through static @property-ies

thanks for your help

RĂ©mi


More information about the Digitalmars-d-learn mailing list