run interpret c++? [duplicate]

浪尽此生 提交于 2019-11-30 12:53:00

问题


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:

  • Have you used any of the C++ interpreters (not compilers)?

回答1:


Take a look at Ch, an embeddable C++ interpreter.

Ch is an embeddable C/C++ interpreter for cross-platform scripting, shell programming, 2D/3D plotting, numerical computing, and embedded scripting. Ch is a free and user-friendly alternative to C/C++ compilers for beginners to learn C/C++.




回答2:


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.




回答3:


Try these:

  • For C/C++: http://sourceforge.net/projects/igcc/
  • Only for C: http://neugierig.org/software/c-repl/



回答4:


CINT (readme) certainly has single-stepping. I'm not sure about modification on the fly, though.




回答5:


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.




回答6:


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.



来源:https://stackoverflow.com/questions/759279/run-interpret-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!