[C] 纯文本查看 复制代码 #ifdef __GNUC__
# define ATTR_PRINTF(one_based_format_index, first_arg) \
__attribute__((format(__printf__, (one_based_format_index), (first_arg))))
# define ATTR_VPRINTF(one_based_format_index) ATTR_PRINTF((one_based_format_index), 0)
#else
# define ATTR_PRINTF((one_based_format_index), (first_arg))
# define ATTR_VPRINTF(one_based_format_index)
#endif
如上代码,这个实际上是实现编译检查自定义printf的格式。在MDK上AC5 因为不满足条件,所以应该定义为空的宏,实际测试上述代码编译有问题,参数空宏定义的话不能嵌套括号。
[C] 纯文本查看 复制代码 ATTR_PRINTF(one_based_format_index, first_arg)
改成上面这样就可以。 |