简体   繁体   中英

Full code paths in clang errors

I am looking for the clang equivalent of the cl command /FC. I need full paths for my build tool to parse out and open the code files with the errors.

https://msdn.microsoft.com/en-us/library/027c4t2s.aspx

You need to specify a fully-qualified or relative path to the file on the command-line instead of only passing in the filename. In the following example the debugger won't know where to find "blah.cc" because I compiled by specifying only the filename:

~ pwd
/mnt/scratch/myproject/src
~ clang++ blah.cc -c -o /mnt/scratch/myproject/build/blah.o
~ cd ../build
~ clang++ *.o -o myprogram

... however, if instead I'd done this:

~ pwd
/mnt/scratch/myproject
~ clang++ /mnt/scratch/myproject/src/blah.cc -c -o /mnt/scratch/myproject/build/blah.o
# or:
~ clang++ src/blah.cc -c -o build/blah.o
# ...

... then it embeds the fully-qualified or relative path into the debug sections.

If you use a partially qualified path, you'll have to tell GDB where to look for the code. You can look at the documentation for it here , though two gdb commands that may be helpful:

# This will cause gdb to look in "path2" instead of "path1"
(gdb) set substitute-path path1 path2
# This allows you to give a list of directories to search for your source.
# note that if you give relative paths on the command-line, it'll concatenate
# these paths and the relative path used at compile-time.
(gdb) set directories path [path ...]

CFLAGS + = -fdiagnostics-absolute-paths

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM