Make C floating point literals float (rather than double)

后端 未结 4 1082
走了就别回头了
走了就别回头了 2020-12-04 17:40

It is well known that in C, floating point literals (e.g. 1.23) have type double. As a consequence, any calculation that involves them is promoted

4条回答
  •  情话喂你
    2020-12-04 17:55

    The -Wunsuffixed-float-constants flag could be used too, maybe combined with some of the other options in the accepted answer above. However, this probably won't catch unsuffixed constants in system headers. Would need to use -Wsystem-headers to catch those too. Could generate a lot of warnings...

提交回复
热议问题