开发者

Is there a C/C++ compiler/linker which is embedable directly in a C/C++ program?

The idea is to generate C/C++ code at run-time, compile it to a shared object, and load that shared object in the current process.

I know it could be done by using an existing compiler installation on the host platform (GCC or MSVC), but in a practical scenario the client don't necessary have such installation. So the idea is to statically link with such compiler and linker.

For example in Java, you can compile .java classes directly from java code. It can be used to generate automatically a Buisness Objects from a databa开发者_如何学运维se schema.


You may be able to do this with the c-language front end (clang) to llvm. The static analyzer built on top of clang may give you some ideas on how to proceed.


There is tinyC: http://bellard.org/tcc/. I know nothing similar for C++.


Google 'c interpreter embed' and you'll get as a first hits

  • http://www.softintegration.com/ (embeddable C/C++ interpreter)
    • review/article here
  • http://code.google.com/p/picoc/ (C only?)

YMMV


As far as I know, such thing can not be done for c or c++. You have to start a new process (in which you execute a compiler), and requires a compiler to be installed.


You might wanna hacve a look at the crack language, based on llvm, it's in early phase but seems quite near from what you try to achieve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜