www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - compatibility of c++ and d on the level of llvm bytecode

reply egordeev <egordeev18 gmail.com> writes:
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
next sibling parent David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
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 16 2016
prev sibling next sibling parent Kai Nacke <kai redstar.de> writes:
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 16 2016
prev sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
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.
May 25 2016