analogdevicesinc / TMC-API

TRINAMIC's IC API
MIT License
199 stars 86 forks source link

Fix a compile-time warning/error with C++ compiler #30

Closed AlexRoman closed 1 year ago

AlexRoman commented 1 year ago

The error is as follows:

In file included from /home/alex/src/xxx/src/motor_task.cpp:19:
/home/alex/src/xxx/tmc/tmc/ic/TMC2209/TMC2209.h:40:13: error: narrowing conversion of '3238854692' from 'unsigned int' to 'int32_t' {aka 'long int'} [-Wnarrowing]
   40 | #define R70 0xC10D0024  // PWMCONF
      |             ^~~~~~~~~~
/home/alex/src/xxx/tmc/tmc/ic/TMC2209/TMC2209.h:73:9: note: in expansion of macro 'R70'
   73 |         R70, 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0  // 0x70 - 0x7F
      |         ^~~

The fix is simple, just use an uint32_t instead of an int32_t.

trinamic-ASU commented 1 year ago

Thank you for your interest in contributing to our project . However, we have some concerns related to the scope of your commits and their possible impact on other parts of our project. We do not guarantee a smooth import of our C files to C++ files and doing so is out of scope of our project. Moreover, we haven't seen any compilation warnings or errors on our side. Given this situation, we suggest that you fix the issue by changing your compiler settings such that it ignores these kinds of warnings/errors. We appreciate your efforts but unfortunately, we cannot accept your merge request at this time. We encourage you to keep contributing to the open-source community.

AlexRoman commented 1 year ago

@trinamic-ASU Thank you for your feedback. The error is definitely related to compiler versions and settings, but frankly the code as written is invalid, as the value overflows an int32_t.

That said, I do appreciate your position and your lack of interest in this. I will close the PR.