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:11:24 +1100 |
commit | 3b3b48892f96e2c81e7887f996fd7ff457acbb5d (patch) | |
tree | 310b836aa91f4f860b3e2cf5cc33c01ebe854904 /py | |
parent | da692d01ac6c09286ee682c0d4a3780777c67a8f (diff) | |
download | micropython-3b3b48892f96e2c81e7887f996fd7ff457acbb5d.tar.gz micropython-3b3b48892f96e2c81e7887f996fd7ff457acbb5d.zip |
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>
Diffstat (limited to 'py')
-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 5c90b1491c..0728fce315 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; |