Skip to content

Commit 8585407

Browse files
authored
Use enum instead of const for float consts with repr C (#591)
Older compilers (eg for esp8266) cannot see that "const uint32_t" is a true constant at compile time, so use an assigned enum instead. Don't do this for object representation D because that requires a 64-bit integer. Signed-off-by: Damien George <damien@micropython.org>
1 parent f2dd223 commit 8585407

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

code/ndarray.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ typedef struct _mp_obj_float_t {
6565
// See above for how to use ULAB_DEFINE_FLOAT_CONST and ULAB_REFERENCE_FLOAT_CONST.
6666

6767
#define ULAB_DEFINE_FLOAT_CONST(id, num, hex32, hex64) \
68-
const uint32_t id = (((((uint32_t)hex32) & ~3) | 2) + 0x80800000)
68+
enum { \
69+
id = (((((uint32_t)hex32) & ~3) | 2) + 0x80800000) \
70+
}
6971

7072
#define ULAB_REFERENCE_FLOAT_CONST(id) ((mp_obj_t)(id))
7173

0 commit comments

Comments
 (0)