#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
  
 
