ElectronicCats / mpu6050

MPU6050 Arduino Library
MIT License
304 stars 119 forks source link

The DEBUG build no longer compiles #80

Closed benpeart closed 6 months ago

benpeart commented 6 months ago

If you attempt to compile with the DEBUG macro defined, the library does not compile with the error:

.pio\libdeps\debug\MPU6050\src\MPU6050_9Axis_MotionApps41.cpp: In member function 'uint8_t MPU6050_9Axis_MotionApps41::dmpInitialize()':
.pio\libdeps\debug\MPU6050\src\MPU6050_9Axis_MotionApps41.cpp:366:17: error: 'productID' was not declared in this scope
     DEBUG_PRINT(productID);

I have submitted a pull request that contains a two-part fix. The first part is to fix the compile error by commenting out the offending DEBUG_PRINT line. The second/better fix is to update the DEBUG_PRINT macros so that the structure of the macros ensures that the code is always validated at compile time but is not called when DEBUG is undefined. This will prevent stale debug code from accumulating when the debug version is not regularly compiled.

AndreaZGuz commented 6 months ago

Hello @benpeart !

Could you please tell me which example are you trying to compile? Also, what board are you selecting to compile the .ino file you want to run?

Thank you.

benpeart commented 6 months ago

I was using MPU6050_6Axis_MotionApps20.h but any example that tries to build with the DEBUG flag set will have this error. If you look the cause is trivial - someone commented out the line in MPU6050_9Axis_MotionApps41.cpp that declares the productID variable but forgot to comment out the DEBUG_PRINT line that uses it.

I've submitted pull request #81 that fixes this with both a simple fix (comment out the line that tries to use productID) and a more robust fix that should prevent these types of errors in the future.

AndreaZGuz commented 6 months ago

Thank you @benpeart for the comments.

Currently, the .ino examples do not have issues during compilation when DEBUG is defined, but you have a point regarding the productID definition. Your pull request will be checked.

Is there another issue we can help you with?

AndreaZGuz commented 6 months ago

Hi @benpeart !

If there are no more questions or issues we can help you with right now, we will close the query. Our colleagues in the dev team will take a look at your pull request.

Please contact us again if necessary.