Thread overview
C linking to D
Dec 01, 2003
Mark Brudnak
Dec 01, 2003
Matthew Wilson
Dec 03, 2003
Ilya Minkov
December 01, 2003
Anyone,

Can D build binaries which are linkable from C?  In other words can I link a bottom level D module/library etc. to a top level C program?

Mark.



December 01, 2003
I can't see any reason why not, so long as you are using C-compatible types, i.e. ptrs not arrays, etc.

"Mark Brudnak" <malibrud@provide.net> wrote in message news:bqedce$2af0$1@digitaldaemon.com...
> Anyone,
>
> Can D build binaries which are linkable from C?  In other words can I link
a
> bottom level D module/library etc. to a top level C program?


December 03, 2003
Matthew Wilson wrote:
> I can't see any reason why not, so long as you are using C-compatible types,
> i.e. ptrs not arrays, etc.

It is necessary to initialise the D runtime (GC, etc.) from the C environment. Then it is necessary to use extern(C) convention in D. Then write headers. Gets more cumbersome than not.

For more information on initialising and shutting down the runtime, see manual chapter on using WinMain entry point in D...

-eye