Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D and C++ currently interoperability status

I'd like to learn D, but I haven't understood well an important thing. How's the current interoperability status between C++ and D?

I'm sure it's impossible to link to C++ compiled binaries, as it doesn't even work with C++ compilers. But what if I have the source code of a C++ library and some D source code. Would it be possible to make them speak? (hopefully in an efficient way).

How about the different C++ versions (C++98, 11, 14, 17 and future versions)?

like image 459
Duns Avatar asked Dec 13 '22 13:12

Duns


1 Answers

D interoperability with C++ has been improved considerably in the last few years. The "Interfacing to C++" section of the "D Specification" is a good start if you want to learn more.You may also want to look at the "magical" dpp project - https://code.dlang.org/packages/dpp .

I do not understand your question about linking... The linker is the same no matter whether you use Assembly, C, C++, D, or any combination of them... You will be able to link C++ libraries, but you may not be able to use all what is inside (depends on what is in the library). I've seen D apps linked against Boost libraries for an example.

like image 157
DejanLekic Avatar answered Dec 25 '22 22:12

DejanLekic