From a02d959ec418ca53ea399d4b9c9d96cc0a2f6c2a Mon Sep 17 00:00:00 2001 From: Dirk Helbig Date: Tue, 23 Jul 2024 21:05:07 +0200 Subject: [PATCH] btstack_debug: avoid gcc extension in logging macro --- src/btstack_debug.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/btstack_debug.h b/src/btstack_debug.h index 9a5e3fb53..59482d3d8 100644 --- a/src/btstack_debug.h +++ b/src/btstack_debug.h @@ -99,30 +99,36 @@ void btstack_assert_failed(const char * file, uint16_t line_nr); #ifdef __AVR__ #define BTSTACK_PRINTF(format, ...) printf_P(PSTR(format), ## __VA_ARGS__) #else -#define BTSTACK_PRINTF(format, ...) printf(format, ## __VA_ARGS__) +#define BTSTACK_PRINTF(...) printf( __VA_ARGS__) #endif #endif #ifdef __AVR__ -#define HCI_DUMP_LOG(log_level, format, ...) hci_dump_log_P(log_level, PSTR("%S.%u: " format), PSTR(BTSTACK_FILE__), __LINE__, ## __VA_ARGS__) +#define HCI_DUMP_LOG_PRINTF(log_level, format, ...) hci_dump_log_P(log_level, PSTR("%S.%u: " format), PSTR(BTSTACK_FILE__), __LINE__, ## __VA_ARGS__) +#define HCI_DUMP_LOG_PUTS(log_level, format) hci_dump_log_P(log_level, PSTR("%S.%u: " format), PSTR(BTSTACK_FILE__), __LINE__) #else -#define HCI_DUMP_LOG(log_level, format, ...) hci_dump_log(log_level, "%s.%u: " format, BTSTACK_FILE__, __LINE__, ## __VA_ARGS__) +#define HCI_DUMP_LOG_PRINTF(log_level, format, ...) hci_dump_log(log_level, "%s.%u: " format, BTSTACK_FILE__, __LINE__, ## __VA_ARGS__) +#define HCI_DUMP_LOG_PUTS(log_level, format) hci_dump_log(log_level, "%s.%u: " format, BTSTACK_FILE__, __LINE__); #endif +#define GET_LOGGER_TYPE_FOR_ARG_COUNT( _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, NAME, ... ) NAME + +#define HCI_DUMP_LOG( ... ) GET_LOGGER_TYPE_FOR_ARG_COUNT(__VA_ARGS__, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PRINTF, HCI_DUMP_LOG_PUTS, UNUSED)( __VA_ARGS__ ) + #ifdef ENABLE_LOG_DEBUG -#define log_debug(format, ...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_DEBUG, format, ## __VA_ARGS__) +#define log_debug(...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_DEBUG, ## __VA_ARGS__) #else #define log_debug(...) (void)(0) #endif #ifdef ENABLE_LOG_INFO -#define log_info(format, ...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_INFO, format, ## __VA_ARGS__) +#define log_info(...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_INFO, ## __VA_ARGS__) #else #define log_info(...) (void)(0) #endif #ifdef ENABLE_LOG_ERROR -#define log_error(format, ...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_ERROR, format, ## __VA_ARGS__) +#define log_error(...) HCI_DUMP_LOG(HCI_DUMP_LOG_LEVEL_ERROR, ## __VA_ARGS__) #else #define log_error(...) (void)(0) #endif