Skip to content

Commit

Permalink
Use enum instead of const for float consts with repr C (#591)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dpgeorge authored Mar 4, 2023
1 parent f2dd223 commit 8585407
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ typedef struct _mp_obj_float_t {
// See above for how to use ULAB_DEFINE_FLOAT_CONST and ULAB_REFERENCE_FLOAT_CONST.

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

#define ULAB_REFERENCE_FLOAT_CONST(id) ((mp_obj_t)(id))

Expand Down

0 comments on commit 8585407

Please sign in to comment.