Compiling with -unittest on a c wrapper
simendsjo
simendsjo at gmail.com
Fri Feb 24 01:18:13 PST 2012
On Fri, 24 Feb 2012 10:06:33 +0100, simendsjo <simendsjo at gmail.com> wrote:
> 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..
Hmm. If I add all the wrapper modules, I'm able to compile.. Guess it's
related. What's the best way to handle this?
More information about the Digitalmars-d-learn
mailing list