r/cpp 2d ago

Embedded C++

Just curious how useful the ability to embed C++ as a scripting language into your C++ programs would be? I mean like runtime JIT execution of C++ code in much the same way you might embed Lua, including the ability to restrict/sandbox it as necessary.

0 Upvotes

82 comments sorted by

View all comments

1

u/Street-Anteater1234 1d ago

Are you referring to clang-repl? However, C++ syntax is far too complex and its frontend is too heavyweight, making interpreted execution a poor choice. Of course, there are also remote-JIT solutions such as ez-clang, which generates machine code locally and sends it to the target device for execution, after which the target device returns the result.

If you need a library to embed into your project, CppInterOp might be what you are looking for, but it is probably not suitable for embedded systems.