Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use clang as a library to implement JIT compilation as stated by other answers. Then, you have to load up the compiled module (say, an .so library).</p> <p>In order to accomplish this, you can use standard dlopen (unix) or LoadLibrary (windows) to load it, then use dlsym (unix) to dynamically reference compiled functions, say a "script" main()-like function whose name is known. Note that for C++ you would have to use mangled symbols. A portable alternative is e.g. GNU's <a href="http://www.gnu.org/software/libtool/manual/libtool.html#Using-libltdl" rel="noreferrer">libltdl</a>.</p> <p>As an alternative, the "script" may run automatically at load time by implementing module init functions or putting some static code (the constructor of a C++ globally defined object would be called immediately).</p> <p>The loaded module can directly call anything in the main application. Of course symbols are known at compilation time by using the proper main app's header files.</p> <p>If you want to easily add C++ "plugins" to your program, and know the component interface a priori (say your main application knows the name and interface of a loaded class from its .h before the module is loaded in memory), after you dynamically load the library the class is available to be used as if it was statically linked. Just be sure you do not try to instantiate a class' object before you dlopen() its module.</p> <p>Using static code allows to implement nice automatic plugin registration mechanisms too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload