C++ Interfacing:'static' array function parameter contradiction

kinke via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 29 12:25:47 PDT 2017


On Saturday, 29 April 2017 at 18:54:36 UTC, سليمان السهمي 
(Soulaïman Sahmi) wrote:
> But still, this needs to be fixed, copy pasting the name 
> mangling is in my opinion just a hack for your specific cpp 
> compiler on your specific platform.

It can't be fixed on the D side as the Visual C++ mangling of 
`float color[3]` as `float * const color` cannot be represented 
in D, see the corresponding DMD issue 
https://issues.dlang.org/show_bug.cgi?id=17359.

Just to be clear, a D declaration `extern(C++) bool 
cppFunc(float[3] color)` isn't compatible with the nearly 
identically looking C++ one, as it implies by-value semantics for 
`color` (not available in C++), that's why DMD doesn't allow it 
and so can't mangle it according to the target's C++ compiler. 
And the C++ byref version `float (&color)[3]` is mangled 
differently again (compatible with D's `ref float[3]`).


More information about the Digitalmars-d-learn mailing list