繁体   English   中英

lang错误中的完整代码路径

[英]Full code paths in clang errors

我在寻找cl命令/ FC的clang等效项。 我需要构建工具的完整路径来解析并打开包含错误的代码文件。

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

您需要在命令行上指定文件的标准路径或相对路径,而不是仅传递文件名。 在以下示例中,调试器将不知道在哪里可以找到“ blah.cc”,因为我仅通过指定文件名进行了编译:

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

...但是,如果我改为这样做:

~ 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
# ...

...然后将完全限定或相对路径嵌入调试部分。

如果使用部分限定的路径,则必须告诉GDB在哪里查找代码。 您可以在此处查看文档,尽管有两个gdb命令可能会有所帮助:

# 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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