ccint: a C/C++ interpreter ccint is a C/C++ interpreter, built on top of Clang and LLVM compiler infrastructure.
supports all C++11/C++14/C++17 features supports for linking static/dynamic libraries high performance: same performance as C/C++ binaries separate parser and execution engine $ git clone git@github.com:llvm/llvm-project.git$ cd llvm-project/clang/tools/$ git clone git@github.com:remysys/ccint.git$ echo "add_clang_subdirectory(ccint)" >> CMakeLists.txt$ cd ../..$ cmake -S llvm -B build -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DCMAKE_BUILD_TYPE=Release$ cd build && make -j16
./clang-ccint --helpUSAGE: clang-ccint [options] <input file>OPTIONS:General options: -I <string> - specify include paths -L <string> - load given libs
/* main.cpp */#include <stdio.h>#include <vector>#include <string>void ccint_main() { std::vector<std::string> vec = {"hello", " world\n"}; for (auto &s : vec) { printf("%s", s.c_str()); }}$ ./ccint main.cpphello world
/* add.h */int add(int, int);/* add.c */int add(int a, int b) { return a + b;}/* main.cpp */#include <stdio.h>#include "add.h"void ccint_main() { printf("32 + 64 = %d\n", add(32, 64));}$ clang -c add.c -o add.o$ ar rcs libadd.a add.o$ ./ccint main.cpp -L ./libadd.a32 + 64 = 96
/* add.h */int add(int, int);/* add.c */int add(int a, int b) { return a + b;}/* main.cpp */#include <stdio.h>#include "add.h"void ccint_main() { printf("32 + 64 = %d\n", add(32, 64));}$ clang -shared -fPIC add.c -o libadd.so$ ./ccint main.cpp -L ./libadd.so32 + 64 = 96
/* add.h */int add(int, int);/* add.c */int add(int a, int b) { return a + b;}/* main.cpp */#include <stdio.h>#include "add.h"void ccint_main() { printf("32 + 64 = %d\n", add(32, 64));}$ clang -shared -fPIC add.c -o libadd.so$ mv ./add.h ..$ ./ccint main.cpp -L ./libadd.so -I ..32 + 64 = 96