gpt4 book ai didi

c++ - Clang 的意外输出

转载 作者:太空宇宙 更新时间:2023-11-03 10:35:52 24 4
gpt4 key购买 nike

我一直在测试 clang-llvm,看看是否值得向我学校的 IT 部门提及将其添加到我们学生编程的机器上。对于我们所有的作业,我们都需要使用 g++ -Wall -W -pedantic-errors *.cpp 进行编译,所以我只是将命令转换为 clang++ -Wall -W -pedantic-错误。我得到了一些我没有预料到的输出:

Attempting to compile...
In file included from test_library.cpp:6:
In file included from ./test_library.h:64:
In file included from ./library.h:167:
./library.hpp:20:23: warning: unused variable 'e' [-Wunused-variable]
catch(Exception & e)
^

而 GCC 编译器不会给出有关 catch block 中未使用变量的错误。有什么我可以做的,这样 Clang 就不会因为 try/catch block 中未使用的变量而感到害怕,同时保持命令类似于 g++ 吗?

Clang-LLVM(v2.7) GNU GCC(v4.4.4) Fedora 13

最佳答案

我有点同意 Mike 的观点,但为了脱离实际,试试这个:

clang++ -Wall -W -pedantic-errors -Wno-unused-variable

我没有经常使用 llvm,但我认为诊断中 [-Wunused-variable] 的意义在于告诉您可以关闭该警告加上 -Wno-unused-variable

关于c++ - Clang 的意外输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3756279/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com