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
[]
= "build.rs"
[]
= "0.4"
[]
= "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 <stdio.h>
}}
fn main() {
unsafe {
cpp!([] {
printf("Hello, World!\n");
});
}
}