Interfacing to C++: Cannot access value from namespace

Andrew Edwards edwards.ac at gmail.com
Sat Sep 7 10:26:16 UTC 2019


I'm running into the following issue when attempting to interface 
with C++:

// C++
========
namespace MySpace
{
     MyType& GetData();
}

struct MyType
{
     // ...
     float continuallyUpdatedValue;
     // ...
};

// call site
MySpace::GetData().continuallyUpdatedValue;

// D
========
extern (C++, MySpace) MyType* GetData();

struct MyType
{
     float continuallyChangingValue; // [1]
}

// call site
MySpace.GetData().continuallyUpdatedValue; // <--- This is not 
being updated by C++

[1] I did not declare any of the other member variables from the 
struct, don't know if this is a source of the problem.


More information about the Digitalmars-d-learn mailing list