mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-07 10:53:17 +02:00
Fix USER_PRINT stripping out uprintf (#25919)
This commit is contained in:
@@ -24,3 +24,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "avr/xprintf.h"
|
#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__)
|
||||||
|
|||||||
+23
-19
@@ -30,8 +30,26 @@
|
|||||||
#include "sendchar.h"
|
#include "sendchar.h"
|
||||||
#include "progmem.h"
|
#include "progmem.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the destination for routing all log data to.
|
||||||
|
*/
|
||||||
void print_set_sendchar(sendchar_func_t func);
|
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
|
* @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
|
* 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"); \
|
_Pragma("GCC diagnostic pop"); \
|
||||||
} while (0)
|
} 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
|
#ifdef USER_PRINT
|
||||||
// Remove normal print defines
|
# define xprintf(fmt, ...) // Remove normal print defines
|
||||||
# undef xprintf
|
#else
|
||||||
# define xprintf(fmt, ...)
|
# define xprintf print_printf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define print(s) xprintf(s)
|
#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 !!!
|
// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!!
|
||||||
|
|
||||||
|
#define uprintf print_printf
|
||||||
|
|
||||||
#define uprint(s) uprintf(s)
|
#define uprint(s) uprintf(s)
|
||||||
#define uprintln(s) uprintf(s "\r\n")
|
#define uprintln(s) uprintf(s "\r\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user