C++ interface problem

Benjamin Thaut via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 29 06:55:44 PDT 2015


On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote:
>
> here is the shortened version of the returned class CSteamID:
> https://gist.github.com/Extrawurst/936f56ceaa87cf287257
>
> this is the shortened interface (no destructors in the rest of 
> the code either):
> https://gist.github.com/Extrawurst/b20dc5ab84132ecab30d
>
> the method `GetFriendByIndex` is the one crashing on win32.

I assume that's because CSteamID is returned by value. Are you 
defining CSteamID in D as a struct? If not you have to because 
only structs can be returned by value. The next problem is that 
CSteamID is 64bits wide, this might be a problem as it can not be 
returned in a single register. You could try changeing the 
definition of GetFriendByIndex on the D side to

ulong GetFriendByIndex(...) and reinterpret the ulong on the D 
side. If that does not work however you are most likely out of 
luck because the way your c++ library returns a value type > 
32-bit is not compatible with what dmd expects. Do you have debug 
symbols for the third party c++ library? Can you step into the 
virtual function call to actually see if it ends up in the 
correct function on the c++ side?

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d-learn mailing list