我正在使用 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
最佳答案
在其他编译器选项中放置-Wconversion
(代码:: block 16)
对于:
int i =0;
int f = 3.14;
i = f;
warning: conversion to ‘int’ alters ‘double’ constant value [-Wfloat-conversion]
我经常使用的一些有用的警告:
-Wall -Weffc++ -Wextra -pedantic -Wfatal-errors -pedantic-errors
关于c++ - 如何在 CodeBlocks 中启用缩小警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43447796/