_Dmodule_ref question

Iain Buclaw ibuclaw at ubuntu.com
Sun Feb 5 05:03:08 PST 2012


On 5 February 2012 10:28, Johannes Pfau <nospam at example.com> wrote:
>
> Is there a reason why _Dmodule_ref can't be defined in a d source file?
> ---------------------
> module test;
>
> extern(C)
> {
>    void* _Dmodule_ref = null;
>    int printf(in char* format, ...);
>
>    void main()
>    {
>        printf("Hello, %s!".ptr, "no runtime".ptr);
>    }
> }
> ----------------------
>
> doesn't compile. but removing the _Dmodule_ref declaration from test.d
> and creating a test.c file:
> ----------------------
> void* _Dmodule_ref;
> ----------------------
> compiles.

Seems to work for me.  Only thing I can point out is that D globals
are thread-local by default, so maybe declare with __gshared ?


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the D.gnu mailing list