From 8c2f5ad4b173ff9e596bfe0f473a7331ff776052 Mon Sep 17 00:00:00 2001 From: m Date: Tue, 15 Apr 2025 20:35:02 -0700 Subject: [PATCH] fix: make semihosting macros compatible with one-argument format strings --- cortex-m-semihosting/src/macros.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cortex-m-semihosting/src/macros.rs b/cortex-m-semihosting/src/macros.rs index f1cc4f3e..d2e43d9c 100644 --- a/cortex-m-semihosting/src/macros.rs +++ b/cortex-m-semihosting/src/macros.rs @@ -36,7 +36,7 @@ macro_rules! syscall1 { #[macro_export] macro_rules! hprint { ($s:expr) => { - $crate::export::hstdout_str($s) + $crate::export::hstdout_fmt(format_args!($s)) }; ($($tt:tt)*) => { $crate::export::hstdout_fmt(format_args!($($tt)*)) @@ -53,10 +53,10 @@ macro_rules! hprintln { $crate::export::hstdout_str("\n") }; ($s:expr) => { - $crate::export::hstdout_str(concat!($s, "\n")) + $crate::export::hstdout_fmt(format_args!("{}\n", format_args!($s))) }; ($s:expr, $($tt:tt)*) => { - $crate::export::hstdout_fmt(format_args!(concat!($s, "\n"), $($tt)*)) + $crate::export::hstdout_fmt(format_args!("{}\n", format_args!($s, $($tt)*))) }; } @@ -67,7 +67,7 @@ macro_rules! hprintln { #[macro_export] macro_rules! heprint { ($s:expr) => { - $crate::export::hstderr_str($s) + $crate::export::hstderr_fmt(format_args!($s)) }; ($($tt:tt)*) => { $crate::export::hstderr_fmt(format_args!($($tt)*)) @@ -84,10 +84,10 @@ macro_rules! heprintln { $crate::export::hstderr_str("\n") }; ($s:expr) => { - $crate::export::hstderr_str(concat!($s, "\n")) + $crate::export::hstderr_fmt(format_args!("{}\n", format_args!($s))) }; ($s:expr, $($tt:tt)*) => { - $crate::export::hstderr_fmt(format_args!(concat!($s, "\n"), $($tt)*)) + $crate::export::hstderr_fmt(format_args!("{}\n", format_args!($s, $($tt)*))) }; }