Description
Currently, compiling mpack for some 8-bit embedded targets (such as Arduino AVR microcontrollers) fails because doubles are just 32-bit floats and not proper 64-bit floating-point numbers:
mpack/src/mpack/mpack-common.h
Line 922 in 6883f6f
If possible, it would be great to make MPack compilable for such targets, even if reading/writing doubles must be unsupported on such targets - for example by making a flag in
mpack-defaults.h
to omit the mpack_load_double
, mpack_store_double
, and mpack_encode_double
functions, and to make mpack_tree_parse_node_contents
and mpack_parse_tag
return false instead of attempting to read doubles on when type 0xcb
(double) is encountered. I've started to try out this idea in a fork I made, and I'll report back on whether I find obvious differences in a few basic use cases between a few 8-bit AVR microcontrollers and a few 32-bit ARM microcontrollers. Caveat is that I've never used mpack before, so maybe my understanding has some crucial gaps about why this wouldn't work or about what is the correct way to disable double reading/writing functionality.
Perhaps more graceful degradation of functionality on AVR-like targets would be to convert 32-bit doubles to and from the 64-bit representations stored in the unions in mpack_load_double
, mpack_store_double
. I'm not sure if it's possible to implement this in a portable way - the closest I've found is somebody's function to read a 32-bit float from a buffer containing a 64-bit floating point representation at https://www.microchip.com/forums/FindPost/258940, and the ArduinoJson library's msgpack deserializer implementation (readDouble
and doubleToFloat
).