Skip to content
/ tccjit Public
forked from jrialland/tccjit

Using libtcc for compiling C at runtime

License

Notifications You must be signed in to change notification settings

beordle/tccjit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

A small C++ wrapper around libtcc (❤️) (https://bellard.org/tcc/)

Compiles code at runtime :

#include "tccjit.hpp"

int main() {

    // generate the code
    jit::Module module(
        "void func(char * txt) {"
        "    printf(\"Hello, %s\\n\", txt);"
        "}"
    );

    // fetch the function
    auto func = module.fn<void(char*)>("func");

    // run it
    func("World");

    return 0;
}

cmake generates a dynamic library that embeds libtcc, so it can be used directly in your c++ project :

g++ -L. -ltccjit example.cpp -o example

About

Using libtcc for compiling C at runtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 62.6%
  • CMake 36.1%
  • Shell 1.3%