Cpp2Rust

    Cpp2Rust/cpp2rust

    Cpp2Rust: Automatic Translation of C++ to Safe Rust

    backend
    clang
    safe-rust
    transpiler
    Rust
    MIT
    319 stars
    21 forks
    319 GitHub watchers
    Updated Nov 2, 2026
    View on GitHub

    Build with Backblaze B2

    SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.

    Explore Backblaze Labs

    Loading star history...

    Where it stands

    Rank, growth pace and release cadence relative to everything GStars tracks.

    The project lists 8 contributors on GitHub.

    Peaked at #44 in the weekly ranking the week of Jul 12, its best in the past year.

    Use Cases & Benefits

    • Translates C++ code into fully safe Rust automatically using clang's AST and a runtime library for pointer semantics.
    • Ensures memory safety by default through a reference counting model and runtime checks, reducing manual Rust unsafe code.
    • Use for migrating legacy C++ projects to safe Rust without rewriting code manually.
    • Use for generating Rust bindings from C++ codebases to leverage Rust's safety in mixed-language projects.
    • Use for benchmarking and comparing safe versus unsafe Rust translations of C++ code for performance analysis.

    Should you depend on it?

    License terms, project hygiene and risks, from GitHub metadata and GStars' snapshots.

    License

    MIT

    Permissive: commercial use, modification and redistribution are allowed with attribution.

    Community files

    • README: present

    Watch-outs

    • No GitHub releases; pin a commit or tag instead of a release.

    General guidance from repository metadata, not legal advice. How we score

    From the README

    Cpp2Rust translates C++ to fully safe Rust automatically. It is a syntax-driven translator based on clang's AST.

    Cpp2Rust's algorithm is described in the paper Cpp2Rust: Automatic Translation of C++ to Safe Rust published at PLDI 2026.

    Cpp2Rust first parses the input C++ file(s) with clang and produces an AST. It then traverses the AST and emits Rust code as strings, inserting calls to the libcc2rs runtime library where needed (e.g., for raw pointer semantics). Finally, the Rust code is pretty-printed using rustfmt to a single .rs file.

    By default the reference counting model is used, which produces fully safe Rust. A generator of unsafe Rust is also available through the --model=unsafe command line argument for debugging and performance comparisons.

    The generated code relies on a runtime library designed to simplify the translation process. C pointers are converted into the Ptr<T> type provided by libcc2rs. Ptr<T> models C pointer semantics, including null, arithmetic, and aliasing, while satisfying Rust's borrow checker through checked run-time operations.

    Excerpt from the Cpp2Rust/cpp2rust README on GitHub (MIT license). © its authors.Read the full README on GitHub

    Daily snapshots

    Stars gained per day, and how forks and open issues moved, from GStars' daily snapshots

    Forks

    21+8

    Open issues

    11-6

    Compared with peers in Backend

    Fastest-growing repositories GStars tracks in this cohort for the week of Nov 1, by 7-day star growth

    Cpp2Rust/cpp2rust compared with Backend repositories by stars, 7-day star growth, health score and last release
    RepositoryStars+7dHealthLast release
    anthropics/skills187.8K+2.9K15—
    DuarteSantos8/openGym19.7K+2.4K602 days ago
    shiyu-coder/Kronos47.0K+2.3K16—
    NationalSecurityAgency/ghidra98.2K+2.3K6414 days ago
    microsoft/VibeVoice56.0K+1.1K29—
    Cpp2Rust/cpp2rust319—35—
    Category median56.0K+2.3K29—

    Discover Repositories

    Search across tracked repositories by name or description