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

ParticlePeter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 28 10:45:37 PDT 2017


On Friday, 28 April 2017 at 17:15:54 UTC, kinke wrote:
> On Friday, 28 April 2017 at 15:56:17 UTC, ParticlePeter wrote:
>> So what next? How can I interface to the cpp function?
>
> *** C++:
>
> bool cppFunc(float (&color)[3])
> {
>     color[0] = 1;
>     color[1] = 2;
>     color[2] = 3;
>     return true;
> }
>
> *** D:
>
> extern(C++) bool cppFunc(ref float[3] color);
>
> void main()
> {
>     float[3] my_color;
>     cppFunc(my_color);
>     assert(my_color == [ 1, 2, 3 ]);
> }

The c++ lib is not mine and your answer implies extra work on the 
c++ from my side. Possible, but not desired, I think calling my 
original c++ function should interface with an d pointer. That 
being said, I think Kagamin is right.


More information about the Digitalmars-d-learn mailing list