Mohammad Javad Naderi
Mohammad Javad Naderi

Reputation: 506

Remove File Name from gcc/g++ Compile Result

I want to remove file names from gcc/g++ compile error messages.

When I run gcc myfolder/temp.c, the result is:

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

But I want this:

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

Is there a gcc flag for that?

Upvotes: 1

Views: 784

Answers (1)

Dima Chubarov
Dima Chubarov

Reputation: 17169

I doubt there is an option for this but you could achieve the same result using standard utilities. For instance with cut(1)

 gcc -c myfolder/temp.c 2>&1 | cut -d: -f2-

Upvotes: 3

Related Questions