且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在运行时编译C ++代码(如Python中的eval)?

更新时间:2023-01-15 20:43:05

请重新考虑您在做什么. C ++和Python在许多方面都是非常不同的语言,尤其是在它们的构建和执行模型中.看来非常不太可能运行时编译是解决您的根本问题(您尚未与我们共享)的真正解决方案.简而言之,C ++并非旨在支持此功能,Python则被设计为支持这种功能.

Please reconsider what you're doing. C++ and Python are very different languages in very many ways, not least in their build and execution models. It seems very unlikely that runtime compilation is the real solution to your underlying problem (which you have not shared with us). Simply put, C++ was not designed to support this, Python was.

从技术上讲,有一些C ++运行时编译的解决方案,但它们需要很多比Python中的eval更多的管理和工作量.但是,它们非常专业,因此再次不可能很好地解决您的基本问题.

Technically, there are a few solutions for runtime compilation of C++, but they require much more management and effort than eval in Python. However, they are pretty specialised and, again, unlikely to be a good solution to your underlying problem.