add cpp
This commit is contained in:
13
cpp/Cargo.toml
Normal file
13
cpp/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "rust_sample_cpp"
|
||||
version = "0.1.0"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
cpp = "0.5.3"
|
||||
|
||||
[build-dependencies]
|
||||
cpp_build = "0.5.3"
|
||||
|
||||
5
cpp/build.rs
Normal file
5
cpp/build.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
extern crate cpp_build;
|
||||
|
||||
fn main() {
|
||||
cpp_build::build("src/main.rs");
|
||||
}
|
||||
16
cpp/src/main.rs
Normal file
16
cpp/src/main.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
#[macro_use]
|
||||
extern crate cpp;
|
||||
|
||||
cpp!{{
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
}}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
cpp!([] {
|
||||
printf("Hello, World!\n");
|
||||
std::cout << "Hello, World2!" << std::endl;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user