糟糕!我刚刚找到了。
主要 clang 文档索引页面的底部:https://clang.llvm.org/docs/index.html https://clang.llvm.org/docs/index.html在最底部的“索引和表格”部分下,有一个“搜索页面”链接。使用该链接,这是我对“-Weverything”的搜索:https://clang.llvm.org/docs/search.html?q=-Weverything https://clang.llvm.org/docs/search.html?q=-Weverything,这让我看到了这里的官方文档!:https://clang.llvm.org/docs/UsersManual.html?highlight=weverything#cmdoption-weverything https://clang.llvm.org/docs/UsersManual.html?highlight=weverything#cmdoption-weverything。完毕!就在那里!
也可以看看:https://clang.llvm.org/docs/UsersManual.html?highlight=weverything#diagnostics-enable-everything https://clang.llvm.org/docs/UsersManual.html?highlight=weverything#diagnostics-enable-everything
我真正关心的部分(强调):
Since -Weverything
启用每一个诊断,我们通常不建议使用它。 -Wall -Wextra
对于大多数项目来说是更好的选择。 Using -Weverything
意味着更新编译器更加困难,因为您接触到的实验诊断可能质量低于默认诊断。如果你使用-Weverything
那么我们建议您在将所有新的编译器诊断添加到 Clang 时解决它们,方法是修复它们找到的所有内容,或者显式禁用该诊断及其相应的诊断Wno-
option.
所以,我的最终建议是使用-Wall -Wextra
用于警告,但不-Weverything
,以及个人而言,not -Wpedantic
(or -pedantic
--同样的事情),因为我经常依赖 gcc 编译器扩展来进行低级嵌入式工作和以硬件为中心的编程,尤其是在微控制器上。
我还强烈建议将所有警告强制转换为错误-Werror
。这对于需要永久运行的安全关键代码和/或嵌入式固件尤其重要,因为它迫使您修复所有警告以使代码完全编译。所以,我的最终建议是这样的,正如我在下面的 github 存储库中进一步描述的那样:
# Apply "all" and "extra" warnings, and convert them all to errors
# to force you to actually abide by them!
-Wall -Wextra -Werror
您可以在我的 GitHub 存储库中阅读我对此主题的更全面的观点和研究:https://github.com/ElectricRCAaircraftGuy/eRCaGuy_hello_world#build-notes https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world#build-notes.
额外说明:-Wpedantic
== -pedantic
:
在 gcc 中,它们是相同的:
-
两者一起列出 https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html.
-Wpedantic
-pedantic
发出严格的 ISO C 和 ISO C++ 要求的所有警告...
在 clang 中,它们在测试和文档方面似乎也相同。铿锵也努力在语法和用法上与 gcc 兼容 https://clang.llvm.org/:“最终用户功能:”...“GCC 兼容性”。
- -pedantic https://clang.llvm.org/docs/UsersManual.html?highlight=weverything#cmdoption-pedantic
- -Wpedantic https://clang.llvm.org/docs/DiagnosticsReference.html?highlight=wpedantic#wpedantic
Related:
- 为什么我应该始终启用编译器警告? https://stackoverflow.com/questions/57842756/why-should-i-always-enable-compiler-warnings