Closed iago-lito closed 1 year ago
Hmnmn, that is weird! If float.h
is undefining and redefining FLT_RADIX
immediately, nothing should be amiss from toml++'s perspective. I suppose the MKL package does something weird with FLT_RADIX
elsewhere and there's some include-order shenanigans going on with the CMake config. I have no idea what to do about it, though. This seems like a bug in the MKL headers.
Can you try replacing toml++'s use of FLT_RADIX
with std::numeric_limits<double>::radix
? i.e. change this line in toml++/impl/forward_declarations.hpp
:
static_assert(FLT_RADIX == 2, TOML_ENV_MESSAGE);
to this:
static_assert(std::numeric_limits<double>::radix == 2, TOML_ENV_MESSAGE);
If that doesn't work, you can #define TOML_DISABLE_ENVIRONMENT_CHECKS
somewhere before you include toml++ and it should work OK. The float radix is only used to check that the local environment is compatible with the TOML spec, and isn't actually used anywhere else.
Replacing the macro invocation by std::*::radix
does fix the problem. And indeed I should maybe report this to intel-mkl. It seems that they broke something ^ ^" Thank you for swift support, and feel free to close then. I'll just need to figure out where to find intel now ^ ^"
you can
#define TOML_DISABLE_ENVIRONMENT_CHECKS
I think I'll go for some more targetted hack instead:
#ifndef FLT_RADIX
#define FLT_RADIX std::numeric_limits<float>::radix
#endif
.. but I just want to get rid of one confusion first: do you expect FLT_RADIX
to be std::numeric_limits<float>::radix
or std::numeric_limits<double>::radix
? (because it seems that DBL_RADIX
also exists)
I think I'll go for some more targetted hack instead [...]
I'd caution against that solution; the standard specifies std::numeric_limits<(float|double|long double)>::radix
in terms of FLT_RADIX
(ref), so you might end up causing compiler errors elsewhere. I'll add a workaround to the toml++ code to detect FLT_RADIX
shenanigans to avoid this in future.
but I just want to get rid of one confusion first [...]
Either would be fine since they should be the same, but floats in TOML++ are (at least) 64-bit so it uses double
everywhere internally. (double
isn't necessarily going to be 64-bit on all platforms, of course, but the other static asserts check for that.)
Wop, thank you for spotting the snag! ^ ^"
FWIW it seems that the error does not occur.. provided you opt into using Intel's proprietary compiler icpx
:\
Ah, right, so I guess MKL assumes you're using that compiler and does #undef FLT_RADIX
because it knows that the compiler has some special behaviour in that area.
That's... unfortunate 😅
Environment
toml++ version and/or commit hash:
Compiler:
C++ standard mode:
Target arch:
Library configuration overrides:
none
Relevant compilation flags: After having installed intel-oneapi-mkl:
Describe the bug
The library compiles fine, until I add the above flag (because the project otherwise uses MKL), then I get:
Steps to reproduce (or a small repro code sample)
main.cpp
CMakeLists.txt
I'm not exactly sure what the error deeply means here. FWIU the
FLT_RADIX
macro is (re-)defined withinintel/oneapi/compiler/latest/linux/compiler/include/float.h:75
to:but I'm not confident what it means or why this would result in "undeclared FLT_RADIX". I'm happy to learn more ^ ^"