关于移植过程中,存在大量LCD log(不定形参...)等调试属性函数宏定义到printf

嵌入式开发过程中,遇到移植第三方协议栈,有时存在大量LCD log等调试属性函数。我们希望保存原生的调试输出信息,通过对LCDlog等调试功能进行printf重新宏定义。

在第三方程序存在大量的调试属性函数,如: 

#define  LCD_UsrLog(format, ...)    
  #define  LCD_ErrLog(format, ...)    

在没有相应的LCD硬件支持,但我们希望保存这些调试输出信息,而不是重新去编写调试信息。


此时,我们可以重新宏定义到printf(format, ...),调试输出信息打印到串口调试软件。

宏定义如下:(##:但应用过程中不存在不定形参...时,消除“,”的错误)

  #define  LCD_UsrLog(format, ...)    printf(format, ##__VA_ARGS__)
  #define  LCD_ErrLog(format, ...)    printf("ERROR: "); printf(format, ##__VA_ARGS__)

实现调试信息打印到串口调试软件上。


附:

MDK hlep文档:

	#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
	void Variadic_Macros_0()
	{
   	  debug ("a test string is printed out along with %x %x %x\n", 12, 14, 20);
	}
IAR help文档:

#define MYSEG "YYY"
#define X(str) __no_alloc_str(str @ MYSEG)
extern void dbg_printf(unsigned long fmt, ...);
#define DBGPRINTF(fmt, ...) dbg_printf(X(fmt), __VA_ARGS__)
void 
foo(int i, double d)
{
 
 
DBGPRINTF("The value of i is: %d, the value of d is: %f", i,d);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值