ldc,betterC模式下的继承才4kb

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() {
    scope b = new B;
    b.sayHello();

命令如下 :ldc2 -betterC %.
scope,在栈上分配.
这样的betterCc++有啥区别?
而且编译后更小.betterC非常强大!!!

posted @ 2020-11-15 09:31  zjh6  阅读(30)  评论(0)    收藏  举报  来源