Since version 6, clang has supported a __fp16
type. I would like to use it, but I need to support other compilers (both clang-based and non-clang-based) as well as older versions of clang, so I need a reliable way to detect support. Unfortunately, I don't see anything in clang's documentation about how to detect it (using __has_feature
, __has_extension
, etc.).
Since clang's version number macros are unreliable, the best solution I have right now is to use __has_warning("-Wpragma-pack")
(the -Wpragma-pack warning was also added in clang 6). I'm hoping that there is a fp16 feature/extension/whatever I can check instead which just isn't documented where I'm looking, but obviously open to other ideas.
So, does anyone know of a better way to detect __fp16
support?
The reliable way to detect support for compiler constructs is to compile an example program that uses that construct. This has been achieved since forever with build systems, for example in CMake with try_compile or AC_COMPILE_IFELSE in autoconf.