Are interfaces supported in Better C mode?

Dibyendu Majumdar d.majumdar at gmail.com
Sat Nov 14 21:46:38 UTC 2020


On Saturday, 14 November 2020 at 21:40:31 UTC, Dibyendu Majumdar 
wrote:
> On Saturday, 14 November 2020 at 21:09:59 UTC, Dibyendu 
> Majumdar wrote:
>> Reading the docs on Better C mode I got the impression that it 
>> should be possible to implement an interface in a struct. Is 
>> this not the case?
>>
>
> I guess it needs to be class?
>

Well this compiles but doesn't link.

import core.stdc.stdio : printf;

extern (C++) interface A {
     void sayHello();
}

extern (C++) class B : A {

     void sayHello() {
         printf("hello\n");
     }
}

extern (C) void main() {
     B b;
     b.sayHello();
}


/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: interfaces.o:(.data._D10interfaces1A11__InterfaceZ+0x0): undefined reference to `_D14TypeInfo_Class6__vtblZ'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: interfaces.o:(.data._D10interfaces1B6__initZ+0x8): undefined reference to `_D10interfaces1B7__ClassZ'




More information about the Digitalmars-d mailing list