Closed tdz closed 7 years ago
Fixes the problem described at https://github.com/mozilla-sensorweb/sensorweb-firmware/issues/32
I've noticed similar failures like the one on Travis, and I haven't figured out how to fix this.
I think I figured it out. You need to add an additional level of braces to the print macro in logger.
diff --git a/src/logger.rs b/src/logger.rs
index 93b715e..9cb8c16 100644
--- a/src/logger.rs
+++ b/src/logger.rs
@@ -8,14 +8,14 @@ use log::{self, LogRecord, LogLevelFilter, LogMetadata, SetLoggerError};
#[macro_export]
macro_rules! print {
- ($($args:tt)*) => {
+ ($($args:tt)*) => {{
// Ignore logging errors. It's not worth killing the program because of
// failed debug output. It would be nicer to save the error and report
// it later, however.
use core::fmt::Write;
let mut console = $crate::cc3200::Console {};
let _ = write!(console, $($args)*);
- }
+ }}
}
#[macro_export]
With that minor addition then all of the examples build cleanly.
With both patches applied, it builds locally and on Travis.
I also figured out that you can look a "macro expanded" version of the source by doing:
xargo rustc --target=thumbv7em-none-eabi --example XXX -- -Z unstable-options --pretty=expanded
Replace XXX by the name of the example you're trying to build. Then it was obvious the outer braces are not included in the generated source.
This looks good to me - r+
Ok, let's take that. Still would like to know if we hit a rustc bug or not...
The macros print() and println() are provided by the logger module. This patch removes them from cc3200.rs.