diff options
| author | weycen <[email protected]> | 2021-12-26 00:26:50 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2021-12-30 01:42:57 +0800 |
| commit | d2e6715ddbc03f5e6d0bb3f44e5eb73135a5b258 (patch) | |
| tree | 319ebb3b9a1eb375c1c120a460648cbc25513ac3 | |
| parent | 88a746377c770f991a3b4e5c8751f2e0675c50e6 (diff) | |
[kernel] Add __attribute__(...) for rt_kprintf() to let the compiler check the format string parameters
Tested in the following environment:
1. Keil uVersion:Arm Compiler v5.06、v6.7、v6.16
2. Atollic TrueSTUDIO for STM32:GNU v6.3.1
3. Code Composer Studio:TI Compiler v20.2.2.LTS、GNU v7.2.1
| -rw-r--r-- | include/rtthread.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/rtthread.h b/include/rtthread.h index d18355c426..8f0f43f7cc 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -570,7 +570,12 @@ void rt_components_board_init(void); #define rt_kprintf(...) #define rt_kputs(str) #else +#if defined(__ARMCC_VERSION) || defined(__GNUC__) || \ + defined(__TI_COMPILER_VERSION__) +int rt_kprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +#else int rt_kprintf(const char *fmt, ...); +#endif void rt_kputs(const char *str); #endif |
