避免浮点警告

时间:2014-05-23 08:33:07

标签: avr floating

我使用avr studio 4编程ATmega128。当我显示浮点值时,我收到警告信息

出现警告信息的行如下:

float temperature;
//{other parts}
fprintf(stderr,"Temp: %0.2f ", temperature);

警告信息是:

../main.c:128:2: warning: format '%f' expects argument of type 'double', but argument 4 has type 'float' [-Wformat]"

当以双倍显示时,我会看到其他随机值。如何摆脱此警告消息?

1 个答案:

答案 0 :(得分:1)

我做了一些进一步的挖掘,警告/实际上是AVRGCC的一个错误。这是marked as resolved in GCC v4.1.0,但判断评论并未正确修复。 2013年8月26日16:52:19 UTC有another fix,可能会根据需要解决问题。

floatdouble促销似乎没有正常运作,因为GCC代码为这两种类型假定了两种不同的尺寸。

相关问题