g++ -Wall 没有关于双重警告->强制转换
在以下代码段中,不会产生任何警告.g++4.4.3 -Wall -pedantic
In the following snippet no warnings are produced. g++4.4.3 -Wall -pedantic
//f is
void f(int );
f(3.14);
double d = 3.14;
int i = d+2;
我强烈记得这是一个警告,类似于可能丢失精度".是被删除了还是我的记忆在欺骗我?
I have a strong recollection of this being a warning, something along the lines of "Possible loss of precision". Was it removed or is my memory playing tricks on me?
如何在 g++ 中将其变成警告?我觉得这是一个有用的警告,还是一个坏主意?
How can i turn this into a warning in g++? I find this a useful warning, or is it a bad idea?
我什至在 http://gcc 都找不到合适的东西.gnu.org/onlinedocs/gcc-4.4.5/gcc/Warning-Options.html
推荐答案
$ gcc -Wconversion test.c
test.c: In function ‘main’:
test.c:3: warning: conversion to ‘int’ from ‘double’ may alter its value
相关文章