execute C++ from String variable -
it possible in c++ execute c++ code string variable. in javascript:
var theinstructions = "alert('hello world'); var x = 100"; var f=new function (theinstructions); return(f());
i want similar javascript in c++. how ?
you need invoke compiler compile code. in addition, need generate code wrap string in function declaration. finally, you'll somehow need load compiled code.
if doing (which not) would:
- concatenate standard wrapper function header around code
- invoke compiler via command line (
system()
) build shared library (.dll
on windows or.so
on linux) - load shared library , map function
- invoke function
this not way want write c code in cases.
Comments
Post a Comment