py/objfloat: Workaround non-constant NAN definition on Windows MSVC.

Recent MSVC versions have changed the definition of NAN to a non-constant
expression!  This is a bug, C standard says it should be a constant.

Good explanation and workaround at: https://stackoverflow.com/a/79199887

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2024-11-20 16:15:20 +11:00
committed by Damien George
parent da692d01ac
commit 3b3b48892f

View File

@@ -47,6 +47,13 @@
#define M_PI (3.14159265358979323846)
#endif
// Workaround a bug in recent MSVC where NAN is no longer constant.
// (By redefining back to the previous MSVC definition of NAN)
#if defined(_MSC_VER) && _MSC_VER >= 1942
#undef NAN
#define NAN (-(float)(((float)(1e+300 * 1e+300)) * 0.0F))
#endif
typedef struct _mp_obj_float_t {
mp_obj_base_t base;
mp_float_t value;