gpt4 book ai didi

c++ - 如何使用 -Wall 启用 -Wunused-variable?

转载 作者:行者123 更新时间:2023-11-30 03:33:31 27 4
gpt4 key购买 nike

我正在使用以下命令构建 C++14。

g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out

如何将 -Wunused-variable 添加到上面的行,以便显示除 -Wunused-variable 之外的所有警告?

最佳答案

来自gcc docs :

You can request many specific warnings with options beginning with ‘-W’, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning ‘-Wno-’ to turn off warnings; for example, -Wno-implicit.

因此,要禁用未使用变量警告,您可以传递 -Wno-unused-variable

关于c++ - 如何使用 -Wall 启用 -Wunused-variable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42789388/

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