From 9e6595b65d9245b7d84ab5ebaef8cfc540266af0 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Wed, 27 Apr 2022 18:33:32 +0200 Subject: [PATCH] Fix integer formating --- src/uart.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/uart.cpp b/src/uart.cpp index 5b5c7bb..84240e7 100644 --- a/src/uart.cpp +++ b/src/uart.cpp @@ -3,6 +3,7 @@ #include #include +#include @@ -27,22 +28,22 @@ namespace sta void UART::print(uint8_t num, IntegerBase base /* = IntegerBase::DEC */) { - printBase(num, base, "%u", sizeof(num)); + printBase(num, base, "%" PRIu8, sizeof(num)); } void UART::print(uint16_t num, IntegerBase base /* = IntegerBase::DEC */) { - printBase(num, base, "%u", sizeof(num)); + printBase(num, base, "%" PRIu16, sizeof(num)); } void UART::print(uint32_t num, IntegerBase base /* = IntegerBase::DEC */) { - printBase(num, base, "%lu", sizeof(num)); + printBase(num, base, "%" PRIu32, sizeof(num)); } void UART::print(size_t num, IntegerBase base /* = IntegerBase::DEC */) { - printBase(num, base, "%u", sizeof(num)); + printBase(num, base, "%z", sizeof(num)); } void UART::print(const char * str) @@ -142,7 +143,7 @@ namespace sta void UART::printDec(uintmax_t num, const char * fmt) { char buffer[64]; - snprintf(buffer, sizeof(buffer), fmt, num); + snprintf(buffer, sizeof(buffer), fmt, static_cast(num)); print(buffer); }