www.digitalmars.com         C & C++   DMDScript  

D - C linking to D

reply "Mark Brudnak" <malibrud provide.net> writes:
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.
Nov 30 2003
parent reply "Matthew Wilson" <matthew.hat stlsoft.dot.org> writes:
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?
Nov 30 2003
parent Ilya Minkov <minkov cs.tum.edu> writes:
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
Dec 03 2003