mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
feat(log): Added PRIuSIZE printf formatter macro
This commit is contained in:
parent
53e3833f44
commit
e4aa326c3a
20
components/log/include/inttypes_ext.h
Normal file
20
components/log/include/inttypes_ext.h
Normal 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
|
@ -24,6 +24,12 @@ tools/test_apps/linux_compatible/driver_mock:
|
||||
enable:
|
||||
- if: IDF_TARGET == "linux"
|
||||
|
||||
tools/test_apps/linux_compatible/generic_build_test:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32c3", "linux"]
|
||||
depends_components:
|
||||
- log
|
||||
|
||||
tools/test_apps/linux_compatible/linux_freertos:
|
||||
enable:
|
||||
- if: IDF_TARGET == "linux"
|
||||
|
@ -0,0 +1,9 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(COMPONENTS main)
|
||||
project(generic_build_test)
|
@ -0,0 +1,4 @@
|
||||
| Supported Targets | ESP32 | ESP32-C3 | Linux |
|
||||
| ----------------- | ----- | -------- | ----- |
|
||||
|
||||
This application is a build test. It checks that certain features can be used on different targets.
|
@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "generic_build_test.c"
|
||||
INCLUDE_DIRS ".")
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include "inttypes_ext.h"
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
size_t size = 47;
|
||||
printf("size is: %" PRIuSIZE "\n", size); // test IDF's PRIuSIZE
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user