Thread overview
[Issue 17359] C++ Interfacing: function with 'static' array parameter cannot be linked (x64)
Apr 29, 2017
Peter Particle
Apr 29, 2017
kinke@gmx.net
Apr 29, 2017
kinke@gmx.net
May 02, 2017
anonymous4
Oct 26, 2017
Walter Bright
Apr 10, 2018
Walter Bright
Mar 01, 2022
Nicholas Wilson
April 29, 2017
https://issues.dlang.org/show_bug.cgi?id=17359

--- Comment #1 from Peter Particle <ParticlePeter@gmx.de> ---
As a work around, we can use Ali's variant and pragma(mangle, "mangle_string"). I found my "mangle_string" with dependency walker.

--
April 29, 2017
https://issues.dlang.org/show_bug.cgi?id=17359

kinke@gmx.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #2 from kinke@gmx.net ---
I think this is no DMD bug. The problem is that Microsoft unlike gcc mangles the `float color[3]` variant as `float * const color`, which can't be represented in D directly (const pointer to mutable data).

--
April 29, 2017
https://issues.dlang.org/show_bug.cgi?id=17359

--- Comment #3 from kinke@gmx.net ---
So the proper workaround for MSVC targets would be:

C++:

bool cppFunc(float color[3])
{
    for (int i = 0; i < 3; ++i) color[i] *= 2;
    return true;
}

D:

pragma(mangle, "?cppFunc@@YA_NQEAM@Z")
extern(C++) bool cppFunc(ref float[3] color);

void main()
{
    float[3] my_color = [ 1, 2, 3 ];
    cppFunc(my_color);
    assert(my_color == [ 2, 4, 6 ]);
}

--
May 02, 2017
https://issues.dlang.org/show_bug.cgi?id=17359

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |C++

--
October 26, 2017
https://issues.dlang.org/show_bug.cgi?id=17359

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |mangling
                 CC|                            |bugzilla@digitalmars.com

--
April 10, 2018
https://issues.dlang.org/show_bug.cgi?id=17359

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
To get the same results in C++ and D:

C++:
  void cppFunc(float (&color)[3]) { }

D:
  extern(C++) void cppFunc(ref float[3] color) { }

Both mangle to:
  ?cppFunc@@YAXAAY02M@Z

--
March 01, 2022
https://issues.dlang.org/show_bug.cgi?id=17359

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m
         Resolution|---                         |WORKSFORME

--