From 4dc6dcb55db8a74d9cc4acd8dbf51add5f95e4e9 Mon Sep 17 00:00:00 2001 From: Lysander Mealy Date: Mon, 2 Dec 2024 09:46:05 -0500 Subject: [PATCH] just deprecate the cstr! macro without removing it Fixes #36 --- src/modules.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules.rs b/src/modules.rs index 887bd94..24cc5bc 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -17,6 +17,18 @@ bitflags! { } } +/// Create a NUL-terminated C string from a string literal +#[macro_export] +#[deprecated(note = "use a C-string literal instead")] +macro_rules! cstr { + () => { + unsafe { core::ffi::CStr::from_bytes_with_nul_unchecked(b"\0") } + }; + ($s:expr) => { + unsafe { core::ffi::CStr::from_bytes_with_nul_unchecked(concat!($s, "\0").as_bytes()) } + }; +} + /// An internal module that the kernel requests from the bootloader. Only /// available with request revision 1 and greater. #[repr(C)]