Given the header file mymodule.h:
void f(void);

I'm creating mymodule.d:
extern(C) void f();

It works fine when compiling with this library, but when I compile with -unittest, I get undefined reference to ModuleInfo: sample.o:(.data+0x210): undefined reference to `_D7mylibrary7mymodule12__ModuleInfoZ'

What am I doing wrong?

I saw the following snippet in deimos/openssl:
// Very boiled down version because we cannot use std.traits without causing // DMD to create a ModuleInfo reference for _d_util, which would require users
// to include the Deimos files in the build.
template ExternC(T) if (is(typeof(*(T.init)) P == function)) {
        static if (is(typeof(*(T.init)) R == return)) {
                static if (is(typeof(*(T.init)) P == function)) {
                        alias extern(C) R function(P) ExternC;
                }
        }
}

.. but I'm not sure if this relates to my problem..

Reply via email to