How to compile D application without the D runtime?

后端 未结 2 1693
故里飘歌
故里飘歌 2021-02-09 04:14

Iv been trying to figure this one out forever, and its starting to annoy me. I understand the D runtime library. What it is, what it does. I also understand that you can compile

相关标签:
2条回答
  • 2021-02-09 04:50
    module main;
    extern(C) __gshared void* _Dmodule_ref;
    extern(C) int main() {
        int a = 2 + 3;
        return 0;
    }
    
    0 讨论(0)
  • 2021-02-09 05:02
    ldc -nodefaultlib -noruntime
    

    I've had success with that. But you'll still want to add:

    extern(C) __gshared void* _Dmodule_ref;
    extern(C) int main() {}
    

    Note that while the runtime is optional, it is required for a lot of the features. You'll be missing array slicing, (dynamic arrays?), GC, and plenty of others. If you accidentally use one of those features, you'll get plenty of warnings about how it can't find some obscure symbol name.

    0 讨论(0)
提交回复
热议问题