dtolnay/cxx

Safe interop between Rust and C++

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 17 minutes ago
Added to GitGenius on September 9th, 2026
Created on December 27th, 2019
Open Issues & Pull Requests: 197 (+0)
GitHub issues: Enabled
Number of forks: 423
Total Stargazers: 6,827 (+0)
Total Subscribers: 59 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 11.5 days
Mean response time: 259.4 days
90th percentile: 959.3 days
Tracked items: 273

How this project is maintained

Around half of the issues opened in the past year never receive a reply. 89% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. Only 7% of issues opened in the past year have been closed. Three people close 91% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 64
New in 7 days: 2
Closed in 7 days: 2
Avg open age: 933 days
Stale 30+ days: 59
Stale 90+ days: 55

Recent activity

Opened in 7 days: 2
Closed in 7 days: 2
Comments in 7 days: 1
Events in 7 days: 2

Top labels

  • help wanted (11)
  • integration (5)
  • windows (4)
  • new binding (3)
  • blocked (2)
  • bug (2)
  • code quality (2)
  • docs (2)

Detailed Description

CXX is a library that provides safe foreign function interface between Rust and C++.

The core problem CXX solves is that traditional FFI approaches using bindgen or cbindgen generate unsafe C-style bindings that create many opportunities for errors. CXX instead defines FFI signatures for both sides of the boundary together in a single Rust module, allowing it to perform static analysis on types and function signatures to uphold both Rust's and C++'s invariants. Code generators then emit the appropriate extern "C" signatures with static assertions to verify correctness at build time. The resulting FFI operates at zero or negligible overhead without copying, serialization, memory allocation, or runtime checks.

A key distinguishing feature is that CXX allows FFI signatures to use native types from either language directly—Rust's String, Box, and Vec alongside C++'s std::string, std::unique_ptr, and std::vector—in any combination. The library provides builtin bindings for standard library types so that method calls are translated idiomatically; for instance, calling len() on a C++ string from Rust invokes the C++ size() member function. This approach means the Rust side of an FFI boundary can remain entirely safe code, shifting the audit burden to the C++ side alone rather than requiring verification of unsafe Rust bindings.

CXX suits projects that need to integrate existing C++ codebases with Rust or gradually migrate between the languages while maintaining type safety guarantees. It requires rustc 1.88 or newer and C++11 or later. The tool integrates with Cargo-managed builds through a procedural macro and build script, and provides a command-line tool for other build systems like Bazel or Buck.

Development activity shows consistent maintenance with regular releases and active CI workflows. The project maintains comprehensive documentation including a tutorial and reference material at its dedicated website. The codebase demonstrates attention to compiler compatibility and build system flexibility across different project configurations.