1

我想从 gcc/g++ 编译错误消息中删除文件名。

当我运行gcc myfolder/temp.c时,结果是:

myfolder/temp.c:5:1: error: unknown type name ‘voi’
myfolder/temp.c:87:6: error: conflicting types for ‘max’
myfolder/temp.c:5:5: note: previous declaration of ‘max’ was here

但我想要这个:

5:1: error: unknown type name ‘voi’
87:6: error: conflicting types for ‘max’
5:5: note: previous declaration of ‘max’ was here

有 gcc 标志吗?

4

1 回答 1

3

我怀疑是否有此选项,但您可以使用标准实用程序获得相同的结果。例如与cut(1)

 gcc -c myfolder/temp.c 2>&1 | cut -d: -f2-
于 2013-01-19T18:45:50.157 回答