Add print, eprint, eprintln, and fix println macros
This commit is contained in:
+34
-10
@@ -1,3 +1,37 @@
|
||||
/// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user