Is there any way to compile additional code at runtime in C or C++?

后端 未结 6 1992
执笔经年
执笔经年 2020-12-24 02:45

Here is what I want to do:

  1. Run a program and initialize some data structures.
  2. Then compile additional code that can access/modify the existing data st
6条回答
  •  旧时难觅i
    2020-12-24 03:26

    Even though LLVM is now used today mostly for its optimizations and backend roles in compilation, as its core it is the Low-Level Virtual Machine.

    LLVM can JIT code, even though the return types may be quite opaque, so if you are ready to wrap your own code around it and don't worry too much about the casts that are going to take place, it may help you.

    However C and C++ are not really friendly for this kind of thing.

提交回复
热议问题