如何在编译时检测long double是否具有扩展精度

kan*_*nna 6 c compiler-construction gcc compilation conditional-compilation

在少数系统中,double与long double相同.如何在编译时检测long double是否为扩展精度而不是double,并将其用于条件编译.

我看到libgcc SIZEOF_DOUBLESIZEOF_LONG_DOUBLE中存在预定义的宏 但是在不同的工具链中没有可移植的.

有C方法吗?

Dav*_*nan 5

你可以比较DBL_MANT_DIGLDBL_MANT_DIG来自float.h.