NRF52: build error, implicit conversion from 'float' to 'double'
Port, board and/or hardware
nrf port, nrf52 board
MicroPython version
mpy latest, nrf52 board
The build process has failed with a compiler configuration issue if support for double is configured.
Build error report:
CC ../../py/formatfloat.c
../../py/formatfloat.c: In function 'mp_format_float':
../../py/formatfloat.c:92:26: error: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Werror=double-promotion]
92 | #define fp_isless1(x) (x < 1.0)
| ^
../../py/formatfloat.c:183:16: note: in expansion of macro 'fp_isless1'
183 | } else if (fp_isless1(f)) {
| ^~~~~~~~~~
../../py/formatfloat.c:336:15: error: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Werror=double-promotion]
336 | f *= FPCONST(10.0);
| ^~
cc1: all warnings being treated as errors
Reproduction
mpconfigport.h
#if NRF51
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#else
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#endif
Expected behaviour
No response
Observed behaviour
Related build error report.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
Unable to compile natmod feature2 example
When I try to compile the features2 example, I get the following error:
GEN build/features2.config.h
CC main.c
main.c: In function 'add':
main.c:26:12: error: implicit declaration of function 'mp_obj_new_float'; did you mean 'mp_obj_new_list'? [-Werror=implicit-function-declaration]
return mp_obj_new_float(mp_obj_get_float(x) + mp_obj_get_float(y));
^~~~~~~~~~~~~~~~
mp_obj_new_list
main.c:26:29: error: implicit declaration of function 'mp_obj_get_float'; did you mean 'mp_obj_is_float'? [-Werror=implicit-function-declaration]
return mp_obj_new_float(mp_obj_get_float(x) + mp_obj_get_float(y));
^~~~~~~~~~~~~~~~
mp_obj_is_float
main.c:26:12: error: return makes pointer from integer without a cast [-Werror=int-conversion]
return mp_obj_new_float(mp_obj_get_float(x) + mp_obj_get_float(y));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [../../../py/dynruntime.mk:137: build/main.o] Error 1
I'm on Raspbian 10 (buster), there is the same error on Win10 and using Cygwin
This is my Makefile, I'm just change ARCH for armv7m because I want to run in Raspberry Pi Pico
# Location of top-level MicroPython directory
MPY_DIR = ../../..
# Name of module
MOD = features2
# Source files (.c or .py)
SRC = main.c prod.c test.py
# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
ARCH = armv7m
# Include to get the rules for compiling and linking the module
include $(MPY_DIR)/py/dynruntime.mk