extern(C++) struct - what is it?

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 16 05:02:11 PST 2016


On Friday, 16 December 2016 at 12:40:19 UTC, Ilya Yaroshenko 
wrote:
> It was in DMD sources.
> How it can be used?

Like any other struct.

> Are methods virtual?

No.

> How multiple inheritance works?

Don't think it works.

> Can this be used in betterC mode?

Yes all it should affect is the mangling.

> What different between classes in C++?

Mangling on MSVC is different for struct and classes, but other 
that that nothing I think. The difference in default visibility 
needs to be consistent regardless of class/struct.

Do note that declaring extern(C++) class makes it a reference 
type, like all classes in D.

Random other notes:
If you're going in the D -> C++ direction, you control there 
should be no gotcha's.
The other way round, you need to make sure that the symbol 
actually exists (if its a template, that it is instantiated).

I think templates work in both directions, i.e. correct mangling 
coming from C++, and from D. I'm not sure that alias parameters 
work as they AFAIK don't have an analog in C++.

>
> Thanks,
> Ilya



More information about the Digitalmars-d-learn mailing list