运行解释 c++?
Is there a way i can run c++ code as interpreted instead of compiled? so i can edit code and write functions on the fly?
Related:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Ch 和 CINT(通常作为 ROOT 系统的一部分)将解释 C++。 然而,我对 CINT 的体验并不好:语言支持不完整(特别是涉及模板的地方),执行速度慢得多,存在诸如变量作用域和循环退出等错误的历史记录,以及(IMO)这比它的价值更麻烦。 作为一种语言,C++ 在解释使用方面的设计非常糟糕。
如果您需要运行解释型代码,为什么不使用 Python 或 Ruby 这样的现代解释型语言呢? 如果需要,可以使用 SWIG 等工具将它们连接到现有的 C/C++ 库。
Ch and CINT (usually as part of the ROOT system) will interpret C++. However, my experience with CINT has not been good: the language support is not complete (particularly where templates are concerned), the execution is much slower, there has been a history of bugs with e.g. variable scope and loop exiting, and (IMO) it's more hassle than it's worth. As a language, C++ is singularly ill-designed for interpreted use.
If you need to run interpreted code, why not use a modern interpreted language like Python or Ruby? A tool like SWIG can be used to connect them to existing C/C++ libraries if needed.
尝试这些:
Try these:
CINT 当然有单步执行。 不过,我不确定是否可以即时修改。
CINT certainly has single-stepping. I'm not sure about modification on the fly, though.
这并不能完全回答你的问题,但也许会有所帮助。
MS C++ 编译器支持“编辑并继续”,允许您停止、进行更改、重新编译和继续。 继续而不关闭您的程序。
This doesnt exactly answer your question, but perhaps it will help.
The MS C++ compiler supports Edit and Continue, which allows you to stop, make changes, recompile & continue without shutting down you program.
我在 CUSEC 演示营看到了关于 ccons 的演示一月。 它的目标是提供一个像 python 一样的交互式解释器。 当时它还处于早期阶段,但仍然给我留下了深刻的印象。
I saw a presentation on ccons at CUSEC's demo camp back in January. Its aim is to provide an interactive interpreter like python's. It was in its early stages then but impressed me none the less.
看一下 Ch,一个嵌入式 C++ 解释器。
Take a look at Ch, an embeddable C++ interpreter.