C++ interop - class vs struct

FreeSlave via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 10 15:37:28 PDT 2014


On Wednesday, 10 September 2014 at 20:43:44 UTC, Walter Bright 
wrote:
> C++ name mangling distinguishes between a class and a struct. 
> This distinction has no semantic meaning, but there it is in 
> the name mangling. In order to interop, we have to have a way 
> to tell D to mangle a struct as a 'class' when interfacing with 
> C++.
>
> I have some ideas, but they're all kinda ugly.
>
> Any ideas?

Just for clarification. I should notice it relates only to msvc 
mangling model, which does not respect equivalence of struct and 
class and use different symbols to mangle them (U and V). There 
is also warning C4099 because of it.
g++ seems to use same mangling regardless of how you declare 
class (with class or struct keyword).

Even if you find good solution by extending language (for 
example, by adding extern(C++-struct)) it would make sense only 
for Windows platforms.


More information about the Digitalmars-d mailing list