Skip to content

Commit d2e6715

Browse files
weycenBernardXiong
authored andcommitted
[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
1 parent 88a7463 commit d2e6715

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/rtthread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,12 @@ void rt_components_board_init(void);
570570
#define rt_kprintf(...)
571571
#define rt_kputs(str)
572572
#else
573+
#if defined(__ARMCC_VERSION) || defined(__GNUC__) || \
574+
defined(__TI_COMPILER_VERSION__)
575+
int rt_kprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
576+
#else
573577
int rt_kprintf(const char *fmt, ...);
578+
#endif
574579
void rt_kputs(const char *str);
575580
#endif
576581

0 commit comments

Comments
 (0)