Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Rust
  3. cxx

cxx

Apache-2.0Rust1.0.200

A safe, zero-overhead FFI bridge for calling C++ code from Rust and Rust code from C++.

Visit WebsiteGitHubGitHub
6.8k stars420 forks0 contributors

What is cxx?

CXX is a library that provides a safe Foreign Function Interface (FFI) mechanism for interoperability between Rust and C++ code. It eliminates the risks associated with unsafe C-style bindings by enabling developers to call functions and use native types from either language while maintaining 100% safety on the Rust side. The library performs compile-time checks on FFI boundaries to uphold language invariants and operates with zero overhead.

Target Audience

Rust developers who need to integrate with existing C++ codebases or libraries, and C++ developers looking to incorporate Rust components into their projects while ensuring memory safety. It's particularly valuable for teams maintaining mixed-language systems where safety and performance are critical.

Value Proposition

Developers choose CXX over alternatives like bindgen or cbindgen because it guarantees safety on the Rust side without runtime overhead, using static analysis to prevent common FFI errors. Its unique selling point is providing idiomatic type support (like Rust's String/Vec and C++'s std::string/std::vector) while maintaining a zero-cost abstraction, unlike serialization-based approaches.

Overview

Safe interop between Rust and C++

Use Cases

Best For

  • Integrating Rust applications with existing C++ libraries or services while ensuring memory safety.
  • Building mixed-language systems where Rust components need to call C++ APIs with complex data types like vectors and strings.
  • Replacing unsafe extern "C" bindings in Rust-C++ projects with a verified, safe FFI layer.
  • Developing plugins or extensions where Rust code must interoperate with C++ host applications.
  • Creating Rust wrappers for C++ libraries that expose idiomatic Rust APIs without manual unsafe code.
  • Projects requiring zero-overhead FFI without serialization, copying, or runtime checks for performance-critical applications.

Not Ideal For

  • Projects involving only Rust or only C++ with no interoperability needs.
  • FFI scenarios requiring support for arbitrary C++ templates or complex inheritance beyond built-in types.
  • Rapid prototyping where the ceremony of defining a bridge module outweighs the benefits over unsafe extern "C" bindings.
  • Use cases dependent on C++ standard library types not yet implemented, like std::map or Rust's Option and HashMap.

Pros & Cons

Pros

Guaranteed Safety

CXX ensures 100% safe Rust code by performing static analysis on FFI boundaries, as stated in the README, eliminating the need to audit the Rust side for memory safety issues.

Zero Overhead Interop

Operates without copying, serialization, or runtime checks, providing performance identical to hand-written unsafe code, as emphasized in the overview section.

Idiomatic Type Support

Allows seamless use of native types like Rust's String and C++'s std::string, with ABI-compatible mappings detailed in the builtin types table for natural APIs.

Flexible Build Integration

Supports both Cargo-based builds via a build script and non-Cargo setups with a command-line tool, as described in the setup sections, accommodating various project structures.

Cons

Limited Type Coverage

Missing support for common types like Rust's Option, HashMap, and C++'s std::map, as admitted in the 'Remaining work' section, which can block certain use cases.

Signature Duplication

Requires function signatures to be typed out twice—once in the implementation and once in the bridge module—increasing maintenance burden, as noted in the comparison with bindgen.

Restrictive Design

Intentionally opinionated and may not handle arbitrary FFI signatures, forcing developers to work around limitations or fall back to unsafe bindings for edge cases.

Complex Non-Cargo Setup

Integrating with build systems like Bazel requires manual steps using the command-line tool, which can be error-prone compared to integrated Cargo workflows.

Frequently Asked Questions

Quick Stats

Stars6,821
Forks420
Contributors0
Open Issues164
Last commit10 hours ago
CreatedSince 2019

Tags

#ffi#c-plus-plus#interoperability#native-bindings#rust#code-generation#static-analysis

Built With

C
Cargo
p
procedural-macros
R
Rust
C
C++

Links & Resources

Website

Included in

Rust56.6k
Auto-fetched 8 hours ago

Related Projects

RustPythonRustPython

A Python Interpreter written in Rust

Stars22,340
Forks1,484
Last commit20 hours ago
PyO3PyO3

Rust bindings for the Python interpreter

Stars16,116
Forks1,016
Last commit20 hours ago
wasm-bindgenwasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript

Stars9,145
Forks1,242
Last commit10 hours ago
NeonNeon

Rust bindings for writing safe and fast native Node.js modules.

Stars8,425
Forks287
Last commit7 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub