使用 __float128 有什么要求?

What are the requirements to use __float128?

我不太确定如何确定系统支持或不支持 __float128 类型。必须满足哪些系统要求才能使其可用,有没有办法检查 C 代码是否满足这些要求? (作为参考,我的系统支持 __int128 但不支持 __float128。)

假设你问的是 GCC,clause 6.12 of the documentation for GCC 10.2 说:

__float128 is available on i386, x86_64, IA-64, and hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable the vector scalar (VSX) instruction set. __float128 supports the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64 other than HP-UX, __float128 is an alias for _Float128. On hppa and IA-64 HP-UX, __float128 is an alias for long double

和:

… In order to use _Float128, __float128, and __ibm128 on PowerPC Linux systems, you must use the -mfloat128 option. It is expected in future versions of GCC that _Float128 and __float128 will be enabled automatically…

我没有看到该类型的源代码内测试,例如指示它的预处理器宏。