From 1a56fbece266337b0f0efe5262f4d36bff997f7a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 7 May 2026 22:33:31 +0100 Subject: [PATCH] Fix `USER_PRINT` stripping out `uprintf` (#25919) --- platforms/avr/_print.h | 6 ++++++ quantum/logging/print.h | 42 ++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/platforms/avr/_print.h b/platforms/avr/_print.h index bf8247c2f3a..7a6ff65d427 100644 --- a/platforms/avr/_print.h +++ b/platforms/avr/_print.h @@ -24,3 +24,9 @@ #pragma once #include "avr/xprintf.h" + +// TODO: Remove xprintf due to conflicts/assumptions on direct library usage +#undef xprintf + +// Export main print function +#define print_printf(fmt, ...) __xprintf(PSTR(fmt), ##__VA_ARGS__) diff --git a/quantum/logging/print.h b/quantum/logging/print.h index 984bc10758b..ffb32a046ea 100644 --- a/quantum/logging/print.h +++ b/quantum/logging/print.h @@ -30,8 +30,26 @@ #include "sendchar.h" #include "progmem.h" +/** + * @brief Configure the destination for routing all log data to. + */ void print_set_sendchar(sendchar_func_t func); +/** + * @def print_printf(fmt, ...) + * @brief Low-level logging entrypoint - should not be called directly + */ +#ifndef NO_PRINT +# if __has_include_next("_print.h") +# include_next "_print.h" // Include the platforms print.h - must export print_printf +# else +# include "printf.h" // Fall back to lib/printf/printf.h +# define print_printf printf +# endif +#else +# define print_printf(fmt, ...) // Remove ALL print defines +#endif + /** * @brief This macro suppress format warnings for the function that is passed * in. The main use-case is that `b` format specifier for printing binary @@ -48,26 +66,10 @@ void print_set_sendchar(sendchar_func_t func); _Pragma("GCC diagnostic pop"); \ } while (0) -#ifndef NO_PRINT -# if __has_include_next("_print.h") -# include_next "_print.h" /* Include the platforms print.h */ -# else -# include "printf.h" // // Fall back to lib/printf/printf.h -# define xprintf printf -# endif -#else -// Remove print defines -# undef xprintf -# define xprintf(fmt, ...) -#endif - -// Resolve before USER_PRINT can remove -#define uprintf xprintf - #ifdef USER_PRINT -// Remove normal print defines -# undef xprintf -# define xprintf(fmt, ...) +# define xprintf(fmt, ...) // Remove normal print defines +#else +# define xprintf print_printf #endif #define print(s) xprintf(s) @@ -108,6 +110,8 @@ void print_set_sendchar(sendchar_func_t func); // // !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!! +#define uprintf print_printf + #define uprint(s) uprintf(s) #define uprintln(s) uprintf(s "\r\n")