From a5b8e43c9cefd0f3f1d0485ee4c5a8119460770d Mon Sep 17 00:00:00 2001 From: Hayden Roche Date: Fri, 25 Aug 2023 10:47:33 -0700 Subject: [PATCH] Fix format specifier for printing CAN message ID in CanMsg.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regarding the X format specifier: C standard §7.21.6.1: "The unsigned int argument is converted to ..." On some platforms (e.g. mbed_nano), uint32_t, which is what's being printed here, is an unsigned long int, so this code causes a compiler warning. The fix is to use the format specifiers from §7.8.1, specifically PRIX32. --- api/CanMsg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/CanMsg.h b/api/CanMsg.h index 5b120344..522e6541 100644 --- a/api/CanMsg.h +++ b/api/CanMsg.h @@ -12,7 +12,7 @@ * INCLUDE **************************************************************************************/ -#include +#include #include #include @@ -68,7 +68,7 @@ class CanMsg : public Printable size_t len = 0; /* Print the header. */ - len = snprintf(buf, sizeof(buf), "[%08X] (%d) : ", id, data_length); + len = snprintf(buf, sizeof(buf), "[%08" PRIX32 "] (%d) : ", id, data_length); size_t n = p.write(buf, len); /* Print the data. */