Skip to content
Snippets Groups Projects
Commit 23098b69 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Add print, eprint, eprintln, and fix println macros

parent 35bdab76
No related branches found
No related tags found
No related merge requests found
/// Print to stdout
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ({
use core::fmt::Write;
let _ = write!($crate::platform::FileWriter(1), $($arg)*);
});
}
/// Print with new line to stdout
#[macro_export]
macro_rules! println {
() => (print!("\n"));
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
/// Print to stderr
#[macro_export]
macro_rules! eprint {
($($arg:tt)*) => ({
use core::fmt::Write;
let _ = write!($crate::platform::FileWriter(2), $($arg)*);
});
}
/// Print with new line to stderr
#[macro_export]
macro_rules! eprintln {
() => (eprint!("\n"));
($fmt:expr) => (eprint!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*));
}
#[macro_export]
macro_rules! strto_impl {
(
......@@ -101,13 +135,3 @@ macro_rules! strto_impl {
num
}};
}
#[macro_export]
macro_rules! println {
($($args:tt),*) => {
{
use core::fmt::Write as _Trait;
writeln!(::platform::FileWriter(1) $(, $args)*).expect("writing a debug message failed");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment