This is pretty simple: don't let the compiler know the original file name from the beginning. Instead
g++ -std=c++11 -O3 -Wall -c my_source.cc -o my_source.o
do the following:
cat my_source.cc | g++ -std=c++11 -O3 -Wall -c -x c++ - -o my_source.o
Note that you need to explicitly specify -x c++ , error messages will obviously no longer contain the file name, and there is one more caveat: when your sources contain relative inclusions, i.e. include in quotation marks ( #include "foo.hpp" ) instead of angle brackets ( #include <foo.hpp> ), they will no longer work, since the compiler cannot reference the file directory, it just sees the byte stream from the channel.
source share