www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - C++ binding issues with "overloading" pragma mangle

reply ParticlePeter <ParticlePeter gmx.de> writes:
Using DMD I can "overload" extern C++ function signatures, but 
this does not work with LDC:

C++ Function:
bool cppFunc( float[3] color );

D binding:
extern(C++):
pragma( mangel, cppFunc.mangleof ) bool cppFunc( ref float[3] 
color );
pragma( mangel, cppFunc.mangleof ) bool cppFunc( float* color );

LDC Error: Function type does not match previously declared 
function with the same mangled name: cppFunc.mangleof

Is this some precaution or is unique mangling really necessary? 
If not, could this requirement be removed?
Jun 22 2017
parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 22 Jun 2017, at 15:53, ParticlePeter via digitalmars-d-ldc wrote:
 Is this some precaution or is unique mangling really necessary? If 
 not, could this requirement be removed?
It is merely a precaution – the requirement could be removed by having LDC insert bitcasts as appropriate on the LLVM IR level. — David
Jun 22 2017
parent ParticlePeter <ParticlePeter gmx.de> writes:
On Thursday, 22 June 2017 at 15:03:05 UTC, David Nadlinger wrote:
 On 22 Jun 2017, at 15:53, ParticlePeter via digitalmars-d-ldc 
 wrote:
 Is this some precaution or is unique mangling really 
 necessary? If not, could this requirement be removed?
It is merely a precaution – the requirement could be removed by having LDC insert bitcasts as appropriate on the LLVM IR level. — David
Thanks, I'll post an issue on github and link this thread.
Jun 22 2017