Skip to content

cortex-m-semihosting: hprint! family of macros do not format strings without arguments #581

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
suaviloquence opened this issue Feb 24, 2025 · 1 comment · Fixed by #591
Closed

Comments

@suaviloquence
Copy link
Contributor

In the hprint! macros:

#[macro_export]
macro_rules! hprint {
($s:expr) => {
$crate::export::hstdout_str($s)
};
($($tt:tt)*) => {
$crate::export::hstdout_fmt(format_args!($($tt)*))
};
}

They do not print format strings with no arguments (e.g., hprint!("{address}") is sugar for hprint!("{}", address), which is a deviation from the stdlib print! macros using format_args!.

If it's acceptable performance-wise, I can submit a PR to use e.g. hstdout_fmt in this case instead of hstdout_str, otherwise I can document this deviation.

@BartMassey
Copy link
Member

I would love to see the macros use hstdout_fmt in all cases; I don't think the performance matters given that it's semihosting anyway.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants