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?
views:
145answers:
3
+5
A:
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
/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() { }
if anyone cares.
Mark Rushakoff
2009-08-15 17:33:09
True, that works, but what about if there's already a complicated build system set up? It'd be nice if I could just add something to CFLAGS to clear up the output.
nicholasbishop
2009-08-15 18:40:26
+1
A:
Sometimes I use a sed script for that (f.e. when using cmake, which always uses full pathes). This can be useful also to sanitize other parts of log, f.e. template names in C++.
liori
2009-08-15 17:39:14