www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Mixed language projects (D and C++)

reply Preetpal <preetpal.sohal gmail.com> writes:
I want to reuse existing C++ code in a new project that I am 
writing in D and I want to use D in an existing C++ code base (it 
is not large). I do not anticipate interop being an issue.

I am wondering if mixing D and C++ is a common practice? If it is 
a common practice, is anyone is currently doing this in an open 
source project that I can use as a reference to learn from.

I am also looking to choose a build system that has IDE support 
(I use Emacs but I want to be able to use tooling with support 
for auto-completion). I have used CMake in the past for a couple 
of C++ projects but I do not want to use it for D projects if it 
is not commonly used or supported. The C++ project I have written 
is currently built using Rake (it is basically a Ruby library 
that allows you to write Makefiles in Ruby). All of my D projects 
have basically been single file projects so far.

This is my first post on this forum so I want to introduce 
myself. I am new to the D programming language (I have been using 
it for about a month for minor projects). I replaced an 
AutoHotKey script using the Windows API that I was using for 
maximizing Windows across multiple monitors on Windows 10. I also 
used D lang for processing data (converted data for use in 
another script, checked data invariants) for commercial purposes.
Feb 19
parent reply Max Haughton <maxhaton gmail.com> writes:
On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote:
 I want to reuse existing C++ code in a new project that I am 
 writing in D and I want to use D in an existing C++ code base 
 (it is not large). I do not anticipate interop being an issue.

 [...]
C++ interop is used every day. The LLVM D compiler, ldc, uses it to talk to LLVM efficiently. There are good resources on it on this very website
Feb 19
parent reply Preetpal <preetpal.sohal gmail.com> writes:
On Friday, 19 February 2021 at 10:01:36 UTC, Max Haughton wrote:
 On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote:
 I want to reuse existing C++ code in a new project that I am 
 writing in D and I want to use D in an existing C++ code base 
 (it is not large). I do not anticipate interop being an issue.

 [...]
C++ interop is used every day. The LLVM D compiler, ldc, uses it to talk to LLVM efficiently. There are good resources on it on this very website
I am looking for suggestions on what build system to use. I took a look at the LDC project but it looks they are writing their own CMake scripts in the repository itself to add support for D to CMake. I was hoping there might be something that others were using with out of box support for D.
Feb 19
parent reply Max Haughton <maxhaton gmail.com> writes:
On Friday, 19 February 2021 at 10:18:28 UTC, Preetpal wrote:
 On Friday, 19 February 2021 at 10:01:36 UTC, Max Haughton wrote:
 On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote:
 I want to reuse existing C++ code in a new project that I am 
 writing in D and I want to use D in an existing C++ code base 
 (it is not large). I do not anticipate interop being an issue.

 [...]
C++ interop is used every day. The LLVM D compiler, ldc, uses it to talk to LLVM efficiently. There are good resources on it on this very website
I am looking for suggestions on what build system to use. I took a look at the LDC project but it looks they are writing their own CMake scripts in the repository itself to add support for D to CMake. I was hoping there might be something that others were using with out of box support for D.
I would keep it simple and use the dub pregenerate step to run any old C++ build process then link as usual.
Feb 19
parent Preetpal <preetpal.sohal gmail.com> writes:
On Friday, 19 February 2021 at 10:21:29 UTC, Max Haughton wrote:
 On Friday, 19 February 2021 at 10:18:28 UTC, Preetpal wrote:
 On Friday, 19 February 2021 at 10:01:36 UTC, Max Haughton 
 wrote:
 On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote:
 [...]
C++ interop is used every day. The LLVM D compiler, ldc, uses it to talk to LLVM efficiently. There are good resources on it on this very website
I am looking for suggestions on what build system to use. I took a look at the LDC project but it looks they are writing their own CMake scripts in the repository itself to add support for D to CMake. I was hoping there might be something that others were using with out of box support for D.
I would keep it simple and use the dub pregenerate step to run any old C++ build process then link as usual.
Thanks for the advice, that's what I am going to do for now.
Feb 19