lassade / c2z

C++ to Zig bindings and transpiler
99 stars 7 forks source link

inspeired by this article uses zig to create zig bindgens for c++

zig cc -x c++ -std=c++11 -Xclang -ast-dump=json {input_file}

Notes

Usage

Setup

  1. make sure zig in your PATH, you will need the version 0.13 and up
  2. build the project and copy the c2z executable from zig-out to your desired location
  3. or just run the project using zig build run -- ARGS

Running it

  1. zig build run -- lib.h or c2z lib.h
  2. pass any clang argument like include and defines e.g. zig build run -- -DNDEBUG -I.\include -target x86-linux -- .\include\lib.h
  3. modify the generated bindings until it works ;) you might need to import cpp.zig it is located in the src folder

Misc

Todo

Test cases

C++ libs

C libs (or with builtin C bindings)