Make gcc/g++ use absolute path for warnings when compiling files in pwd
Is there a way to make gcc use the absolute path when printing errors found in files compiled in the current directory?
For instance the following does what I want when print errors:
g++ -I. -I../../.. /home/some/path/somefile.cpp
but I want to achieve the same with some开发者_Python百科thing like:
g++ -I. -I../../.. somefile.cpp
I want warnings and errors to be formatting something like:
/home/some/path/somefile.cpp:299:52: warning: some warning
There is no way to do this with gcc itself, but it's trivial with a wrapper script, installed as "gcc", "g++", etc in a directory before /usr/bin
in your PATH:
#! /bin/sh
sourcefile="$1"; shift
case "$sourcefile" in
/*) ;;
*) sourcefile="$PWD/$sourcefile" ;;
esac
exec "/usr/bin/${0##*/}" "$sourcefile" "$@"
... provided that you always put the source file first in your compiler invocation (you'll have to tweak your Makefiles).
精彩评论