让GCC警告预处理文件
GCC显示了.c文件的行号,在我的情况下,它是使用其他宏定义的宏,使用更多的宏来定义。文件?
bla.c
#include <stdlib.h>
#include <stdio.h>
#define PRINT(a) printf("%d\n", (a));
int main()
{
double a = 2.5;
PRINT(a);
return 0;
}
它将打印包含打印(a)(第10行)的行的警告,但我希望它打印包含printf的行(“%d \ n”,(a));;来自预处理文件(第1837行)
预处理文件:
<other code above>
int main()
{
double a = 2.5;
printf("%d\n", (a));;
return 0;
}
GCC shows line numbers for the .c file, which in my case is a macro that is defined using other macros, which are defined using even more macros, etc. Is there a way to have GCC give the line numbers for the preprocessed .i file instead?
bla.c
#include <stdlib.h>
#include <stdio.h>
#define PRINT(a) printf("%d\n", (a));
int main()
{
double a = 2.5;
PRINT(a);
return 0;
}
It will print the warning for the line containing PRINT(a) (line 10), but I want it to print the line containing printf("%d\n", (a));; from the preprocessed file (line 1837)
preprocessed file:
<other code above>
int main()
{
double a = 2.5;
printf("%d\n", (a));;
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用选项
-no-no-no-cpp -p
获取:-no-No-integrated-cpp
选项会导致预处理和编译器作为真正单独的通过,在其中运行它们之间只有通信是预处理器输出。在这种模式下,预处理器通常包括指令在其输出中以从原始文件中标识源线号。
-p
选项抑制它们。然后,编译器通行证没有有关原始文件的行号的信息,并且只能打印预处理器输出的行号。Use the options
-no-integrated-cpp -P
to get:The
-no-integrated-cpp
option causes the preprocessor and compiler to run as truly separate passes, where the only communication between them is the preprocessor output.In this mode, the preprocessor would normally include
#line
directives in its output to identify source line numbers from the original file. The-P
option suppresses them. Then the compiler pass has no information about the original file's line numbers, and can only print the line numbers of the preprocessor output.