Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

ccint - a C/C++ interpreter, built on top of Clang and LLVM compiler infrastructure

License

NotificationsYou must be signed in to change notification settings

remysys/ccint

Repository files navigation

ccint is a C/C++ interpreter, built on top of Clang and LLVM compiler infrastructure.

ccint internals

features

  • 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

build

$ 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

usage

./clang-ccint --helpUSAGE: clang-ccint [options] <input file>OPTIONS:General options:  -I <string>                                        - specify include paths  -L <string>                                        - load given libs

examples

  • print "hello world"
/* 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
  • link static library
/* 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
  • link dynamic library
/* 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
  • specify include paths
/* 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

About

ccint - a C/C++ interpreter, built on top of Clang and LLVM compiler infrastructure

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp