What compilers can I use to communicate C ++ with D?

I want to create a program with a combination of C ++ and D, and I would like to be able to work on it as a single project.

My understanding is that I can use some D compiler to output * .obj files, then I can do the same with some C ++ compiler, and then link all * .obj files into one binary file, thatโ€™s right ?

If this is correct, can I use any C ++ compiler with any D compiler? Or am I limited to certain combinations like DMD-DMC, LDC-Clang and GDC-GCC?

Which linker am I using?

And what standard library am I using?

+5
source share
1 answer

In theory, you could mix compilers, but in practice, from time to time you will have an object file format and standard problems with mixing libraries, especially on 32-bit Windows. It would be hard, but not so bad in other places, since most things are based on de facto standards such as MSVC and gcc.

Win32: use dmC ++ (digital mars compiler and C runtime) with dmd OR g ++ and gdc. Other combinations may be made, but erratic. The best way to mix code in Win32 across compiler families is to build a DLL with a C or COM api and use this from D.

Win64: Since dmd uses Microsoft's 64-bit format and the C library, you should have a bit of trouble mixing dmd with Visual C ++ code. I am not sure about g ++ on Windows64 with dmd.

Most other platforms, including Linux: dmd works well with g ++, like gdc + gcc. I'm not sure if ldc and g ++ are compatible, but ldc should work fine with other LLVM-based compilers on any platform.

+7
source

Source: https://habr.com/ru/post/1208900/


All Articles