可以将gcc配置为不在警告/错误消息中打印完整路径? [英] Can gcc be configured to not print out a full path in warning/error messages?

查看:115
本文介绍了可以将gcc配置为不在警告/错误消息中打印完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当gcc输出警告或错误时,它会显示包含错误的文件的完整路径。是否有一个标志将输出缩短为文件名?

When gcc prints out a warning or error, it shows the full path of the file that contains the error. Is there a flag to shorten the output to just the filename?

推荐答案

这取决于您如何调用gcc:

It just depends on how you invoke gcc:


/tmp/c$ gcc -Wall bad.c
bad.c:1: warning: return type defaults to ‘int’
bad.c: In function ‘main’:
bad.c:1: warning: control reaches end of non-void function

vs


/tmp/c$ gcc -Wall /tmp/c/bad.c
/tmp/c/bad.c:1: warning: return type defaults to ‘int’
/tmp/c/bad.c: In function ‘main’:
/tmp/c/bad.c:1: warning: control reaches end of non-void function

vs

vs


/tmp/c$ gcc -Wall ../../tmp/c/bad.c
../../tmp/c/bad.c:1: warning: return type defaults to ‘int’
../../tmp/c/bad.c: In function ‘main’:
../../tmp/c/bad.c:1: warning: control reaches end of non-void function

bad.c的内容只是

where contents of bad.c are just

main() { }

如果有人在意。

这篇关于可以将gcc配置为不在警告/错误消息中打印完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆