首页 > 解决方案 > 为什么不支持 __float128?

问题描述

因此,我尝试使用__float128-type 在 C 中进行非常精确的数学运算。

我的代码看起来像这样:

#include <stdio.h>

int main() {
    __float128 num;
}

我尝试在没有任何选项的情况下编译它:

gcc -o test test.c

我得到的错误是:

test.c:4:5: error: __float128 is not supported on this target

我的 gcc 是在 x86 Macbook 上使用 Homebrew 安装的。

标签: cgcc

解决方案


我的 gcc 是在 x86 Macbook 上使用 Homebrew 安装的。

你可能已经这样做了,但是gcc你运行来编译你的测试程序实际上是伪装成 GCC 的 Apple clang,如果你这样做,你会看到gcc -v。Apple clang 不支持 __float128,但真正的 GCC 支持。使用您/usr/local/bin/gcc-11 -o test test.c安装的真正的GCC,然后它应该可以成功编译。


推荐阅读