【发布时间】:2020-03-29 05:12:12
【问题描述】:
为什么我们不能在浮点数据类型中使用任何修饰符?
#include <stdio.h>
int main(void)
{
signed float a;
short float b;
return (0);
}
如果尝试使用它,编译器会给出编译时错误。
error: both ‘signed’ and ‘float’ in declaration specifiers
signed float a;
error: both ‘short’ and ‘float’ in declaration specifiers
short float b;
为什么编译器会显示这个错误?
【问题讨论】:
-
因为
float始终是签名的,并且具有固定的大小。 -
(注意:在独立环境(例如没有操作系统的嵌入式系统)中,大部分语言都是实现定义,你会看到一个短浮动,但理解这不是标准 C) 见 5.1.2.1 Freestanding environment
-
学习 C 标准,例如n1570
标签: c linux gcc floating-point