Are interfaces supported in Better C mode?

Dibyendu Majumdar mobile at
Sun Nov 22 00:21:20 UTC 2020

On Saturday, 21 November 2020 at 23:48:06 UTC, Dibyendu Majumdar 
> 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?

Looks like this works with DMD and LDC:

import core.stdc.stdio : printf;

extern (C++) abstract class A {
     void sayHello();

extern (C++) class B : A {
     override void sayHello() {

extern (C) void main() {
     scope b = new B;

So - replacing 'interface' with 'abstract class' solved it.
Also need to use 'new' to allocate. Compiler doesn't complain 
about the null value.

More information about the Digitalmars-d mailing list