Skip to content

Generating C code interface from CPP using clang libtooling

License

Notifications You must be signed in to change notification settings

theidexisted/CPP2C

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPP2C

This is simple tool to generate a C interface from C++ source code using clang libtooling. CPP2C currently is a proof of concept, and only applies to https://github.com/samanbarghi/uThreads, to generate the C interface. The code is explained in details in this blog post.

Building and Installation

git clone https://github.com/samanbarghi/CPP2C
cd CPP2C
mkdir build
cmake ..
make
sudo make install

Run it over uThreads source code

git clone https://github.com/samanbarghi/uThreads
cd uThreads
cpp2c include/uThreads.h -- -x c++ -I./src -I/usr/include/x86_64-linux-gnu/c++/5/ -I/usr/include/c++/5.4.0 -std=c++11

Output

You can find the output in outpu folder: cwrapper.h is the header that should be included in C files, and cwrapper.cpp is in C++ and is responsible to convert C++ pointers to C and vice versa.

About

Generating C code interface from CPP using clang libtooling

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 93.9%
  • CMake 6.1%