diff options
author | Angus Gratton <angus@redyak.com.au> | 2024-11-20 16:15:20 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-11-28 23:56:21 +1100 |
commit | 564ef28ad2ca1c0fb302ac3f46d5f2d07de353de (patch) | |
tree | e17c28ce2c0e3a526570eea322999199bff75c54 | |
parent | 7118942a8c03413e0e85b9b42fc9e1b167966d57 (diff) |
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>
-rw-r--r-- | py/objfloat.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/py/objfloat.c b/py/objfloat.c index 5c90b1491..0728fce31 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -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; |