Struct default constructor - need some kind of solution for C++ interop

Daniel Kozak via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 7 05:30:11 PDT 2016


Dne 7.9.2016 v 14:07 Ethan Watson via Digitalmars-d napsal(a):

> On Wednesday, 7 September 2016 at 11:42:40 UTC, Dicebot wrote:
>> If it is so, I'd call it a major extern(c++) bug.
>
> The documentation seems to be correct. I can't extern( C++, class ) or 
> extern( C++, struct ) on an object, even in DMD 2.071.2-beta3.
>
> But ignoring that. My first member is offset by 8 bytes, even in an 
> extern( C++ ) class. I assume it's just blindly sticking a vtable in 
> there regardless of if I actually define virtual functions or not.
>
> But regardless. Making it a class is still a bad idea since in this 
> exact example it needs to exist on the stack/within an objects scope, 
> which means you then need to further hack around with emplacement and 
> wrappers and blah.
>
> Binary matching, non-trivial constructors, and treating C++ objects 
> like the value types they are will be required to make Binderoo work 
> effortlessly. I've got two out of three of those. Not having any one 
> of those is something of a deal breaker unless I get an effective 
> workaround.
I belive there is no way how to achive what you want, maybe it could be 
possible to extent
extern (C++) syntax for structs, so it will be possible define this() 
for this specific structs


More information about the Digitalmars-d mailing list