clang错误中的完整代码路径

4

“cl”?这与common lisp有什么关系? - too honest for this site
1
大概 cl 是 Visual Studio 的东西。 - Brian Vandenberg
是的,cl是随Visual Studio附带的编译器。 - mojobojo
我的对clang编译器参数的研究表明,没有这样的功能。 - user3629249
2个回答

6

CFLAGS+= -fdiagnostics-absolute-paths


0

你需要在命令行中指定完全限定或相对路径,而不仅仅是传递文件名。在下面的示例中,调试器将不知道如何找到“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在何处查找代码。 您可以查看此处的文档here,不过两个可能有用的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 ...]

我明白了。所以我的解决方案是获取工作目录并将其添加到我的源文件中。编辑:在我弄清楚代码标记之前,不小心按下了回车键。SRCDIR = $(pwd) SRCFILE =“$ SRCDIR / src / Testing.cc” cd build clang -g $ SRCFILE -o Testing cd .. - mojobojo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接