【发布时间】:2014-11-15 16:59:11
【问题描述】:
是否可以向 g++ 添加额外的警告标志,以便它会警告我以下代码中未初始化的 b 变量?
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a;
while (a>0) b++;
cout << a;
}
编辑:我忘了提到我已尝试打开另一个问题中列出的标志: Flags to enable thorough and verbose g++ warnings 但没有触发。 (“发痒!”正如我在下面了解到的那样。)
【问题讨论】:
-
你试过
g++ -Wall -Wextra吗? -
我的测试显示没有来自 GCC 的警告,其中包含大量警告组(-Wall、-Wextra、-pedantic),并且 Clang 发出警告。
-
您可以添加编译标志,即。 -墙。 stackoverflow.com/questions/11714827/…
-
什么优化级别?
-
谷歌:GCC 警告
标签: c++ g++ compiler-warnings