Page 1 of 1

MICROPY_OBJ_REPR_C causes 'identifier "mp_float_t" is undefined'

Posted: Mon Nov 30, 2015 4:22 pm
by igorgatis
I'm trying to use MICROPY_OBJ_REPR_C but it fails with:

Code: Select all

 identifier "mp_float_t" is undefined
Should it include mpconfig.h?

In time: if I'm using a 32-bit (big endian) platform, what representation model should I use? A, B, C or D? And why?

Re: MICROPY_OBJ_REPR_C causes 'identifier "mp_float_t" is undefined'

Posted: Mon Nov 30, 2015 5:17 pm
by dhylands
Here's my interpretation of the various MICROPY_OBJ_REPR's (I was surpised that there weren't any summary comments in the obj.h file)

A - 31 bit small int and qstrs can be packed into an mp_obj_t

B - I think that this was intended for 16-bit PIC port. It still packs in a small int and a qstr, but it needs 2 bits for both, and the qstr and small int both occupy odd pointer values.

C - 31 bit small int, qstr, and a 30-bit float are packed into an mp_obj_t. This would allow reduced memory consumption for floats, and would allow floats to be used from within ISRs. I wonder if a variant that allowed 31-bit floats and 30-bit small ints might be more appropriate?

D - Increases the mp_obj_t to 64-bits, but allows almost a 64-bit float to be represented in an mp_obj_t. I saw a comment somewhere that had the bit layouts, bit can't seem to find it any more.

Re: MICROPY_OBJ_REPR_C causes 'identifier "mp_float_t" is undefined'

Posted: Tue Dec 01, 2015 9:46 am
by Damien
The comments and bit representations for the different object models are in py/mpconfig.h. To use repr C you need to also #define MICROPY_FLOAT_IMPL MICROPY_FLOAT_IMPL_FLOAT.