编译和运行c ++代码运行时 [英] compile and run c++ code runtime

查看:119
本文介绍了编译和运行c ++代码运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何编译你的c ++代码,而你的程序已经运行?



后来我想运行该代码。



我想这样做,因为我想做一个游戏,教会你编程,所以用户必须在游戏运行时测试代码。 / p>

感谢任何帮助

解决方案

如果你选择一种设计有嵌入在心里的语言 - 像LUA或python。对于C ++,你必须去寻找非常笨拙和脆弱的东西,如调用一个外部编译器(这也是一个物流的噩梦,当运输你的游戏),或一些复杂的,如在游戏中集成一个编译器(可能用llvm组件,但...)



此外,对于教学编程,C ++可能不是最好的语言:)


Does anyone know how to compile your c++ code wich you write while your program is already running?

And later i would like to run that code.

I want to do this because I am trying to make a game that woul teach you programing and so the user would have to write the code while the game is running and test it.

Thanks for any help

解决方案

You'd have an easier time if you chose a language that was designed with embedding in mind - like LUA or python. For C++, you'd have to go for something extremely clumsy and fragile like invoking an external compiler (which is also a logistics nightmare when shipping your game), or something as complex as integrating a compiler in your game (probably doable with llvm components, but...)

Also, for "teaching programming", C++ probably isn't the best language :)

这篇关于编译和运行c ++代码运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆