Can you create a library with LDC and link to it with clang++?

Manu turkeyman at gmail.com
Wed Sep 23 23:45:38 UTC 2020


On Thu, Sep 24, 2020 at 9:35 AM Ruby The Roobster via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> Can you create a library(.lib) with ldc and port it to clang++?
> e.g.
>
> //test.d
> module test;
> import std.stdio;
> void hi()
> {
> writeln("hello");
> }
>
> //test.cpp(links to test.lib which contains test.hi
> #include <iostream>
> extern "D" void hi();
> void main() {
> hi();
> }
> //Hopefully prints "hi"
>

Of course. This is critically important functionality for many users.
Except, you should use `extern(C++)` in your D code, and no need to extern
in your C++ code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200924/611b1e5d/attachment.htm>


More information about the Digitalmars-d mailing list