Closed curiousleo closed 4 years ago
Rust 2018 brings Path Clarity.
The current crate example uses pre-"Path Clarity" syntax to import the cpp! macro: https://docs.rs/cpp/0.5.4/cpp/#librs.
cpp!
Using the example without extern crate (as is the new default according to my understanding of the 2018 edition documentation) looks like this:
extern crate
use cpp::{cpp, __cpp_internal, __cpp_internal_closure}; cpp!{{ #include <iostream> }} fn main() { let name = std::ffi::CString::new("World").unwrap(); let name_ptr = name.as_ptr(); let r = unsafe { cpp!([name_ptr as "const char *"] -> u32 as "int32_t" { std::cout << "Hello, " << name_ptr << std::endl; return 42; }) }; assert_eq!(r, 42) }
It works, but only when bringing the internal macros __cpp_internal and __cpp_internal_closure into scope.
__cpp_internal
__cpp_internal_closure
Perhaps there is a way to structure the macros such that
use cpp::cpp;
is all that's need to use the cpp! macro in a 2018 edition Rust project?
Right, i guess it should be fixed to use $crate::__cpp_internal and so for all macro. Do you want to do the change?
$crate::__cpp_internal
Rust 2018 brings Path Clarity.
The current crate example uses pre-"Path Clarity" syntax to import the
cpp!
macro: https://docs.rs/cpp/0.5.4/cpp/#librs.Using the example without
extern crate
(as is the new default according to my understanding of the 2018 edition documentation) looks like this:It works, but only when bringing the internal macros
__cpp_internal
and__cpp_internal_closure
into scope.Perhaps there is a way to structure the macros such that
is all that's need to use the
cpp!
macro in a 2018 edition Rust project?