Pav*_*kin 4 c printf gcc language-lawyer half-precision-float
示例代码:
#include <stdio.h>
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>
#ifdef FLT16_MAX
_Float16 f16;
int main(void)
{
printf("%f\n", f16);
return 0;
}
#endif
Run Code Online (Sandbox Code Playgroud)
调用:
# gcc trunk on linux on x86_64
$ gcc t0.c -std=c11 -Wall
Run Code Online (Sandbox Code Playgroud)
预期诊断:
<nothing>
Run Code Online (Sandbox Code Playgroud)
实际诊断:
t0.c:9:14: warning: format '%f' expects argument of type 'double', but argument 2 has type '_Float16' [-Wformat=]
9 | printf("%f\n", f16);
| ~^ ~~~
| | |
| | _Float16
| double
Run Code Online (Sandbox Code Playgroud)
这是否意味着在__STDC_WANT_IEC_60559_TYPES_EXT__AND 下如果FLT16_MAX定义了 gcc 不知道printf可以与 一起使用_Float16?是否应该有所了解?
另外:尽管printf("%f\n", f);.whenf是 a ,float但上面不会出现任何警告format '%f' expects argument of type 'double', but argument 2 has type 'float'。使困惑。
| 归档时间: |
|
| 查看次数: |
471 次 |
| 最近记录: |