ANSI C标准中有几个常用的标准预定义宏:

LINE:在源代码中插入当前源代码行号;

FILE:在源文件中插入当前源文件名;

DATE:在源文件中插入当前的编译日期

TIME:在源文件中插入当前编译时间;

STDC:当要求程序严格遵循ANSI C标准时该标识被赋值为1;

__cplusplus:当编写C++程序时该标识符被定义。

头文件 debug_macro.h

#ifndef DEBUG_MACRO_H
#define DEBUG_MACRO_H

#include <stdio.h>

#ifdef __DEBUG

#define DEBUG(formate, ...) fprintf(stderr,"FILE:"__FILE__"\nLINE%d:\n""error:"formate"\n", __LINE__, ##__VA_ARGS__)/*如果__VA_ARGS__为空则去掉逗号*/
#else

#endif

#endif

相关文章:

  • 2021-05-14
  • 2021-12-20
  • 2021-12-23
  • 2021-09-02
  • 2021-07-15
  • 2022-12-23
  • 2021-10-06
  • 2022-03-08
猜你喜欢
  • 2021-11-10
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2021-11-13
相关资源
相似解决方案