BetterC classes

kinke via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 20 07:27:12 PST 2016


On Tuesday, 20 December 2016 at 13:30:54 UTC, Kagamin wrote:
> On Friday, 16 December 2016 at 18:29:33 UTC, Ilya Yaroshenko 
> wrote:
>> Undefined symbols for architecture x86_64:
>>   "__D14TypeInfo_Class6__vtblZ", referenced from:
>>       __D8cppclass2Hw7__ClassZ in cppclass-7ed89bd.o
>
> By using typeid you request the class' TypeInfo, and it pulls 
> quite a lot.

The failure reason is a different one - apparently each class 
(incl. extern(C++)) _must_ feature at least one virtual function, 
as a vtbl pointer as first member is expected in multiple places 
(frontend too, not just backend). Linking fails as the vtable is 
empty. Tested with DMD 2.071, and that fails too, regardless of 
`-betterC`.
If there's no good reason for this, it may be considered a bug, 
as it prevents treating simple C++ classes as reference types on 
the D side.


More information about the Digitalmars-d-learn mailing list