22 releases

0.4.0 Jul 9, 2018
0.3.2 Sep 24, 2017
0.3.1 Jul 12, 2017
0.2.1 Mar 22, 2017
0.0.12 Nov 19, 2015

#15 in FFI

Download history 97/week @ 2018-09-19 168/week @ 2018-09-26 198/week @ 2018-10-03 54/week @ 2018-10-10 301/week @ 2018-10-17 175/week @ 2018-10-24 137/week @ 2018-10-31 438/week @ 2018-11-07 219/week @ 2018-11-14 221/week @ 2018-11-21 227/week @ 2018-11-28 175/week @ 2018-12-05 70/week @ 2018-12-12

448 downloads per month
Used in 9 crates (8 directly)

MIT/Apache

15KB
160 lines


lib.rs:

This crate cpp provides macros that allow embedding arbitrary C++ code.

Usage

This crate must be used in tandem with the cpp_build crate. A basic Cargo project which uses these projects would have a structure like the following:

crate
|-- Cargo.toml
|-- src
    |-- lib.rs
|-- build.rs

Where the files look like the following:

Cargo.toml

[package]
build = "build.rs"

[dependencies]
cpp = "0.4"

[build-dependencies]
cpp_build = "0.4"

build.rs

extern crate cpp_build;

fn main() {
    cpp_build::build("src/lib.rs");
}

lib.rs

#[macro_use]
extern crate cpp;

cpp!{{
    #include 
}}

fn main() {
    unsafe {
        cpp!([] {
            printf("Hello, World!\n");
        });
    }
}

Dependencies

~1.5MB
~28K SLoC