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

12345swordy alexanderheistermann at gmail.com
Thu Sep 24 00:24:36 UTC 2020


On Wednesday, 23 September 2020 at 23:45:38 UTC, Manu wrote:
> 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.
If we want a good mass adoption rate then we should aim for 
importing c header files c99 edition.

-Alex



More information about the Digitalmars-d mailing list