On Mon, Sep 13, 2021 at 07:07:01PM +0200, Tobias Burnus wrote: > Regarding FreeBSD: Does this output different values? – If yes, we know > what to do, otherwise – hmm. > > [...] > > > > Wouldn't it be better to use the __LDBL_* macros anyway and not rely on > > > float.h? The header doesn't want to test what float.h tells about the > > > long double type, but what the compiler knows about it. > > I originally wrote the code to use the internal GCC __LDBL_* macros as > > you suggest, but Tobias complained that then the gfortran-provided .h > > file could not be used to compile the C parts of the program with some > > other C compiler. > For instance, clang does not seem to provide those - and in some cases, > it can be useful to mix gfortran code with code complied by other > compilers (icc, clang, ...). > > Maybe it needs to first check the internal macros and then look for > > the float.h versions if it can't find them? > > I think that makes sense. (Adding a comment that #include <float.h> is > for non-GCC compilers, only.)
At least according to godbolt and my tests, both clang and icc predefine those macros too. But there are other C compilers, sure. So we'd need #if defined (__LDBL_MAX__) && defined (__LDBL_*_) // whatever we need #else #include <float.h> ... #endif or so. Jakub