标签: c++ codeblocks compiler-warnings type-narrowing
我正在使用codeblocks IDE
int main() { int i =0; int f = 3.14; i = f; //must give me a warning message, possible loss data. }
为什么编译没有显示缩小的警告信息? 如何启用?
注意:我已将编译器选项修复为-std = c ++ 11 -Wall
答案 0 :(得分:2)
-Wconversion
for:
int i =0; int f = 3.14; i = f;
警告:转换为'int'会改变'double'常量 值[-Wfloat-conversion]
我总是使用一些有用的警告:
-Wall -Weffc++ -Wextra -pedantic -Wfatal-errors -pedantic-errors