当gcc打印出警告或错误时,它将显示包含错误的文件的完整路径。是否有一个标志可以将输出缩短为仅文件名?
最佳答案
这仅取决于您如何调用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
/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
where contents of bad.c are just
main() { }
如果有人在乎。
关于gcc - 可以将gcc配置为不在警告/错误消息中打印出完整路径吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1282392/