Documentation
  • Coverage
  • 65%
    13 out of 20 items documented0 out of 9 items with examples
  • Size
  • Source code size: 15.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.11 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • robertknight/rust-cmacros
    1 1 2
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • robertknight

rust-cmacros

Build Status

Rust library to assist with parsing and translating #define macro definitions from C header files to corresponding Rust code for use with bindings to external libraries.

Intro

To use libraries with a C interface from Rust, rust-bindgen can be used to generate Rust bindings automatically. It does not translate constants or functions defined as macros in C headers to Rust code however.

rust-cmacros is a simple and fairly dumb library which helps to fill this gap.

It has two basic functions:

  • extract_macros() parses the source of a C header file and extracts C macro definitions
  • generate_rust_src() takes as input a set of extracted macros and a translator function and generates Rust code.