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

ParticlePeter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 28 23:22:03 PDT 2017


On Saturday, 29 April 2017 at 01:49:56 UTC, Atila Neves wrote:
> On Friday, 28 April 2017 at 18:41:22 UTC, kinke wrote:
>> On Friday, 28 April 2017 at 18:07:49 UTC, ParticlePeter wrote:
>>> Interesting, your example corresponds to my third case, the 
>>> linker error. I am on Window, building an x64 App, afaik in 
>>> that case the MS Visual Studio linker is used instead of 
>>> optilink. Will add your findings to the bug report.
>>
>> Apparently Microsoft's C++ compiler doesn't mangle `float 
>> arg[3]` parameters identically to `float* arg`:
>>
>> void cppSArray(float color[3]) => ?cppSArray@@YAXQEAM at Z
>> void cppPtr(float* color) => ?cppPtr@@YAXPEAM at Z
>
> The worst part about that is mangling aside, the two 
> declarations are identical to the compiler.
>
> Atila

In this context, can anybody explain [1], in particular, in this 
case, one should extern( C++ ) void cppSArray( ref float[3] color 
);

instead of:
extern( C++ ) void cppSArray( float* color );

Others and me in this discussion seem to agree that parameter 
(float color[3]) is equivalent to (float* color) in C++ world.

[1] http://dlang.org/spec/interfaceToC.html#passing_d_array


More information about the Digitalmars-d-learn mailing list