Compiling a mixed D and C++ project?

Manu turkeyman at gmail.com
Tue Sep 3 07:49:44 UTC 2019


On Mon, Sep 2, 2019 at 11:15 PM Kyle De'Vir via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> Supposedly, C++ classes are the same as C structs, or something,
> and could be interchanged when mixing C / C++ code.
>
> Would an opaque pointer work, perhaps...

C++ classes or structs with vtables are the same as D classes. C++
classes or structs without vtables are the same as D struct.
In this case, you should be using a D `extern(C++) class` so that it
matches the C++ code.
If you try exactly what I wrote, it might work better.

And you should use extern(C++) everywhere instead of extern(C),
otherwise you won't know when you've made mistakes that cause
segfaults. C declarations don't carry argument types, to extern(C)
can't tell you when functions don't match.


More information about the Digitalmars-d mailing list