Crate cpp[−][src]
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
ⓘThis example is not tested
extern crate cpp_build; fn main() { cpp_build::build("src/lib.rs"); }
lib.rs
ⓘThis example is not tested
#[macro_use] extern crate cpp; cpp!{{ #include <stdio.h> }} fn main() { unsafe { cpp!([] { printf("Hello, World!\n"); }); } }
Macros
cpp |
This macro is used to embed arbitrary C++ code. |
cpp_class |
This macro allow to wrap a relocatable C++ struct or class that might have destructor or copy constructor, instantiating the Drop and Clone trait appropriately. |