feat(log): Added PRIuSIZE printf formatter macro

This commit is contained in:
Jakob Hasse
2024-03-20 16:41:22 +08:00
parent 53e3833f44
commit e4aa326c3a
6 changed files with 56 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/*
* This header provides PRIuSIZE, a printf formatter macro for size_t which is similar to the macros
* PRIuX defined in inttypes.h. It is necessary because size_t has different width on different
* platforms (e.g., Linux and ESP32). The alternative would be always casting parameters
* to a certain type in printf and logging functions.
*/
#if __SIZE_WIDTH__ == 64 // __SIZE_WIDTH__ is defined by both GCC and Clang
#define PRIuSIZE "lu"
#else
#define PRIuSIZE "u"
#endif