macro_rules! to_c_str {
($s:expr) => { ... };
}Expand description
Converts a Rust string to a C string pointer.
This macro creates a CString from a Rust string and returns its raw pointer.
Warning: This macro panics if the conversion fails. Consider using
[to_cstring!] for safer error handling.
§Panics
Panics if the string contains interior null bytes.
§Examples
ⓘ
use osal_rs::to_c_str;
extern "C" {
fn set_name(name: *const core::ffi::c_char);
}
let name = "FreeRTOS Task";
unsafe {
set_name(to_c_str!(name));
}