g++ -Wall not warning about double-gt; int cast(g++ -Wall 没有关于双重警告-gt;强制转换)
问题描述
在以下代码段中,不会产生任何警告.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
这篇关于g++ -Wall 没有关于双重警告->强制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:g++ -Wall 没有关于双重警告->强制转换
基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
