Skip to content

Commit 564ef28

Browse files
projectgusdpgeorge
authored andcommitted
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>
1 parent 7118942 commit 564ef28

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

py/objfloat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
#define M_PI (3.14159265358979323846)
4848
#endif
4949

50+
// Workaround a bug in recent MSVC where NAN is no longer constant.
51+
// (By redefining back to the previous MSVC definition of NAN)
52+
#if defined(_MSC_VER) && _MSC_VER >= 1942
53+
#undef NAN
54+
#define NAN (-(float)(((float)(1e+300 * 1e+300)) * 0.0F))
55+
#endif
56+
5057
typedef struct _mp_obj_float_t {
5158
mp_obj_base_t base;
5259
mp_float_t value;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy