<command-line>: note: this is the location of the previous definition

lxue07 / 2024-10-23 / 原文

代码中定了#define DEBUG(format,...) printf(""format"\n", ##__VA_ARGS__ )

编译参数为DEBUG时会报错:

debug.h:8: warning: "DEBUG" redefined

<command-line>: note: this is the location of the previous definition

原因:

<command-line> 代表在gcc的命令行里已经定义了这个宏,但是在源文件里又重新定义了一次

由于编译为DEBUG版本时,编译命令参数中已经有了DEBUG这个参数,所以此处会报重复定义,但是编译为RELEASE版本时不会报该错误。