Merge branch 'feature/log_priusize_macro' into 'master'

feat(log): Added PRIuSIZE printf formatter macro

See merge request espressif/esp-idf!29725
This commit is contained in:
Jakob Hasse
2024-03-21 10:41:49 +08:00
6 changed files with 56 additions and 0 deletions

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