www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - extern(C++) struct - what is it?

reply Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
It was in DMD sources.
How it can be used?
Are methods virtual?
How multiple inheritance works?
Can this be used in betterC mode?
What different between classes in C++?

Thanks,
Ilya
Dec 16 2016
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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
Dec 16 2016
parent Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
On Friday, 16 December 2016 at 13:02:11 UTC, Nicholas Wilson 
wrote:
 On Friday, 16 December 2016 at 12:40:19 UTC, Ilya Yaroshenko 
 wrote:
 [...]
Like any other struct. [...]
Thank you Nicholas
Dec 16 2016
prev sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 16 December 2016 at 12:40:19 UTC, Ilya Yaroshenko 
wrote:
 It was in DMD sources.
 How it can be used?
 Are methods virtual?
 How multiple inheritance works?
 Can this be used in betterC mode?
 What different between classes in C++?

 Thanks,
 Ilya
See also https://dlang.org/spec/cpp_interface.html in particular https://dlang.org/spec/cpp_interface.html#classes
Dec 16 2016