--- main.d
module main;

extern(C) __gshared int foo;

import std;
void main()
{
    import foo : func;
    func;

    writeln(foo);
}

--- foo.d
module foo;
extern extern(C) __gshared int foo;

void func() {
    foo++;
}

The __gshared is irrelevant to it working between modules, but it is relevant if you want C compatibility between threads (NOTE: extern(C) sets mangling, otherwise the module would be encoded in its name).

Reply via email to