Xcode DEBUG 宏定义报错

#define __DEBUG__
#ifdef __DEBUG__
#define DEBUG(format,...) printf("File: "__FILE__", Line: %05d: "format"/n", __LINE__, ##__VA_ARGS__)
#else
#define DEBUG(format,...)
#endif
以上在STM32 System Workbench 编译通过,但是在Xcode 9.3 (Apple LLVM version 9.1.0 (clang-902.0.39.1))上编译C程序会提示错误:

Invalid suffix on literal; C++11 requires a space between literal and identifier
Fix insert" "
No matching literal operator for call to 'operator""__FILE__' with arguments of types 'const char *' and 'unsigned long', and no matching literal operator template

需要在format前面和__File__前后都添加空格,修改成
#define __DEBUG__
#ifdef __DEBUG__
#define DEBUG(format,...) printf("File: " __FILE__ ", Line: %05d: " format "/n", __LINE__, ##__VA_ARGS__)
#else
#define DEBUG(format,...)
#endif

但是还是会有提示 
'DEBUG' macro redefined
把DEBUG替换成 Mylog 就好了
#define __Mylog__
#ifdef __Mylog__
#define Mylog(format,...) printf("File: " __FILE__ ", Line: %05d: " format"/n", __LINE__, ##__VA_ARGS__)
#else
#define Mylog(format,...)
#endif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值