Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5b8e43

Browse filesBrowse files
committed
Fix format specifier for printing CAN message ID in CanMsg.h.
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.
1 parent 50a27fb commit a5b8e43
Copy full SHA for a5b8e43

File tree

1 file changed

+2
-2
lines changed
Filter options

1 file changed

+2
-2
lines changed

‎api/CanMsg.h

Copy file name to clipboardExpand all lines: api/CanMsg.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* INCLUDE
1313
**************************************************************************************/
1414

15-
#include <stdint.h>
15+
#include <inttypes.h>
1616
#include <string.h>
1717

1818
#include <Arduino.h>
@@ -68,7 +68,7 @@ class CanMsg : public Printable
6868
size_t len = 0;
6969

7070
/* Print the header. */
71-
len = snprintf(buf, sizeof(buf), "[%08X] (%d) : ", id, data_length);
71+
len = snprintf(buf, sizeof(buf), "[%08" PRIX32 "] (%d) : ", id, data_length);
7272
size_t n = p.write(buf, len);
7373

7474
/* Print the data. */

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.