The Bic Pen
The Bic Pen

Reputation: 1157

g++ print source-mapped file path in error

I have a C++ file that I'm compiling with g++ with the -ffile-prefix-map option. Is there a way to tell g++ to print the remapped file name when there are build errors? That way, clickable file names in my terminal would point to the correct source files.

For example, these commands:

mkdir cpp_test
echo 'invalid' > cpp_test/a.cpp
g++ -ffile-prefix-map=cpp-test/a.cpp=hello.cpp -g cpp-test/a.cpp -o cpp-test/a.out

print the error:

cpp-test/a.cpp:1:1: error: ‘invalid’ does not name a type
    1 | invalid
      | ^~~~~~~

while I want it to print:

hello.cpp:1:1: error: ‘invalid’ does not name a type
    1 | invalid
      | ^~~~~~~

Is that possible?

Upvotes: 0

Views: 29

Answers (0)

Related Questions