sparkfun / MPU-9250_Breakout

66 stars 50 forks source link

min is undefined #17

Closed dizcza closed 1 year ago

dizcza commented 1 year ago

When the firmware is linked against your lib, I get the error that min is undefined

https://github.com/sparkfun/MPU-9250_Breakout/blob/5aa492079056d0eaf508b00d8fcd5f491e7d8d2c/Libraries/Arduino/src/util/inv_mpu.c#L1364

platformio.ini

lib_deps = 
  sparkfun/SparkFun MPU-9250 Digital Motion Processing (DMP) Arduino Library@^1.0.0
PaulZC commented 1 year ago

Hi Danylo (@dizcza ),

min is a function which returns the minimum of two values. It is usually in math.h. I'm guessing that your platformio board package does not include it?

Best wishes, Paul

dizcza commented 1 year ago

I'm guessing that your platformio board package does not include it?

I don't know. Here is the full config

[env:frogboard]
platform = espressif32
board = frogboard
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
lib_ldf_mode = deep
lib_deps = 
  sparkfun/SparkFun MPU-9250 Digital Motion Processing (DMP) Arduino Library@^1.0.0
build_flags = -Os
  -DCORE_DEBUG_LEVEL=5

I think it's better to import math.h in your code rather than relying on board packages. You can as well do things like

#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif  /* min */
PaulZC commented 1 year ago

We do import math.h:

https://github.com/sparkfun/MPU-9250_Breakout/blob/5aa492079056d0eaf508b00d8fcd5f491e7d8d2c/Libraries/Arduino/src/util/inv_mpu.c#L24

With respect, I think this is an issue for platformio and/or whoever looks after the frogboard.

Best wishes, Paul