Thread overview
compatibility of c++ and d on the level of llvm bytecode
May 16, 2016
egordeev
May 16, 2016
David Nadlinger
May 17, 2016
Kai Nacke
May 25, 2016
Stefan Koch
May 16, 2016
Hello, everyone,
just curious, can we achive compatibility of c++ programs with d programms, i.e. can we use c++ functions, classes, etc. in d programs relying on compatibility of bytecodes, generated by Clang and LDC, and not on the level of ABI?
If so, what are the obstacle if they are exist?
May 16, 2016
On 16 May 2016, at 14:20, egordeev via digitalmars-d-ldc wrote:
> can we achive compatibility of c++ programs with d programms, i.e. can we use c++ functions, classes, etc. in d programs relying on compatibility of bytecodes, generated by Clang and LDC, and not on the level of ABI?

Clang and LDC will almost certainly differ in the format of the byte code they emit. However, it should always be possible to just bitcast the values (data, function pointers) appropriately to make them compatible.

 — David
May 17, 2016
On Monday, 16 May 2016 at 13:20:12 UTC, egordeev wrote:
> Hello, everyone,
> just curious, can we achive compatibility of c++ programs with d programms, i.e. can we use c++ functions, classes, etc. in d programs relying on compatibility of bytecodes, generated by Clang and LDC, and not on the level of ABI?
> If so, what are the obstacle if they are exist?

Hi egordeev,

it depends on your goal. The LLVM bytecode is not independent of the target system. E.g. differences in the ABI are also reflected in the byte code.

But as David said: in most cases you can work around problems using a bitcast.

Regards,
Kai
May 25, 2016
On Monday, 16 May 2016 at 13:20:12 UTC, egordeev wrote:
> Hello, everyone,
> just curious, can we achive compatibility of c++ programs with d programms, i.e. can we use c++ functions, classes, etc. in d programs relying on compatibility of bytecodes, generated by Clang and LDC, and not on the level of ABI?
> If so, what are the obstacle if they are exist?

Have a look at calypso which integrates ldc and clang.