# mozilla/cbindgen

A project for generating C bindings from Rust code

Repository: https://github.com/mozilla/cbindgen
Canonical: https://ross.abutalabs.com/products/cbindgen
Language: Rust
License: MPL-2.0
License Family: copyleft
Last push: 2026-08-22T18:46:24+00:00

## Health v2 (maintenance only)
Score: 91/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 75, longevity 100
- inputs: {"age_days": 3430, "days_push": 11, "days_rel": 84, "gap_med": 70, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2945, forks 386 (observed 2026-08-28T04:07:31.184695+00:00)

## What it is
cbindgen is a tool that generates C and C++11 header files from Rust crates that expose a public C API. It can be used as a standalone CLI program or embedded as a Rust library in build scripts, and its output reflects Rust's actual type layout and ABI guarantees.

## Use cases
- generate C headers from a Rust library
- create C++ bindings for Rust code for FFI
- automate header generation in a build.rs build script
- expose a Rust crate to C or C++ consumers
- keep C header files in sync with Rust source code

## When to choose
- you maintain a Rust library with a cdylib or staticlib C API and need matching headers
- you want machine-generated headers that reflect Rust's ABI guarantees instead of hand-written ones
- you need both C and C++11 headers emitted from the same crate
- you want header generation integrated into your build process

## When to avoid
- you need bindings for languages other than C or C++ (consider alternatives like uniffi or PyO3)
- your Rust crate does not expose a public C API
- you need guaranteed support for an unusual edge case, since feature development is ad hoc and gaps may require filing issues or contributing patches

## Facets
- artifact type: cli-tool
- maturity: active
- function: compiler, developer-tools, parser
- domain: developer-tools, programming-languages, cross-platform
- platform: rust, cpp, c, cli, cross-platform
- tags: ffi, bindings, code-generation, c-headers, rust-interop

## Member repositories
- mozilla/cbindgen (main) score 91

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:31.184695+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:32:54.529513+00:00, confidence not recorded.
  - readme: https://github.com/mozilla/cbindgen (fetched 2026-08-28T04:07:31.184695+00:00, sha 7c3c6ad06a05)
  - registry_crates: https://crates.io/api/v1/crates/cbindgen (fetched 2026-08-29T09:48:05.598096+00:00, sha 882d589bb1f5)
- Data as of 2026-08-30T08:39:29.467469+00:00.
