如何在CodeBlocks中启用缩小警告?

时间:2017-04-17 08:20:37

标签: c++ codeblocks compiler-warnings type-narrowing

我正在使用codeblocks IDE

编写c ++程序
int main()
{
int i =0;
int f = 3.14;
i = f; //must give me a warning message, possible loss data.
}

为什么编译没有显示缩小的警告信息? 如何启用?

注意:我已将编译器选项修复为-std = c ++ 11 -Wall

1 个答案:

答案 0 :(得分:2)

其他编译器选项中的

put -Wconversion

(code :: block 16)

enter image description here

for:

int i =0;
int f = 3.14;
i = f;
  

警告:转换为'int'会改变'double'常量   值[-Wfloat-conversion]

我总是使用一些有用的警告:

enter image description here

-Wall -Weffc++ -Wextra -pedantic -Wfatal-errors -pedantic-errors