Skip to main content

cstring

Macro cstring 

Source
macro_rules! cstring {
    ($string:literal) => { ... };
}
Available on crate feature alloc only.
Expand description

Convenience macro to create a \0-byte terminated alloc::ffi::CString from a literal string

This macro requires the alloc feature. In allocation-free builds, use valgrind_print instead.

The string literal passed to this macro must not contain or end with a \0-byte. If you need a checked version of alloc::ffi::CString you can use alloc::ffi::CString::new.

ยงSafety

This macro is unsafe but convenient and efficient. It is your responsibility to ensure that the input string literal does not contain any \0 bytes.