How to compile D application without the D runtime?

后端 未结 2 1694
故里飘歌
故里飘歌 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 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.

提交回复
热议问题