[2.0.x] Squelch compiler warnings with -Wall#11889
[2.0.x] Squelch compiler warnings with -Wall#11889thinkyhead merged 3 commits intoMarlinFirmware:bugfix-2.0.xfrom
Conversation
dc22ca8 to
61c117b
Compare
- EepromEmulation_Due.cpp:
- Fixed several comparisons between signed and unsigned values
- Added parenthesis around "&" operator where compiler suggested they be added.
- stepper_indirection.cpp:
- Corrected unused variables
- M911-M915.cpp:
- Corrected unused variables.
61c117b to
bf8fd51
Compare
ada5a78 to
8310559
Compare
| #define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0) | ||
| #define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0) | ||
| #define TMC_SAY_PWMTHRS_E(E) do{tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0) | ||
| #define TMC_SET_PWMTHRS_E(E) do{tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0) |
There was a problem hiding this comment.
E_AXIS_N needs extruder to be defined when DISTINCT_E_FACTORS is enabled, so this can't be left out. However, an UNUSED(extruder) could be added to the end of each of these blocks to suppress the warning, without affecting the case where DISTINCT_E_FACTORS is enabled.
There was a problem hiding this comment.
E_AXIS_N needs extruder to be defined when DISTINCT_E_FACTORS is enabled, so this can't be left out.
Oh, I see. I was blindsided by the macros.
There was a problem hiding this comment.
Also, just curious, why the do{}while(0)? Isn't this just equivalent to plain old curly braces? Like this:
#define TMC_SAY_PWMTHRS_E(E) {const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }
There was a problem hiding this comment.
Compilers have been known to complain about semicolons in strange locations, but these days they don't seem to care as much — and will even ignore the trailing comma in an array declaration. Using do{...}while(0) is just the most-compatible old-school method to group code for even the strictest compiler, and I stick to it because it requires the semicolon and promotes good coding practice.
#define TMC_SAY_PWMTHRS_E(E) do{ ... }while(0)
TMC_SAY_PWMTHRS_E(1) // compiler complains because no semicolon
TMC_SAY_PWMTHRS_E(2); // compiler happy because semicolonThere was a problem hiding this comment.
Ah. I was not aware of older compilers complaining about the semicolon at the end of blocks. The idiomatic use of do/while makes a lot more sense now. Thank you for the explanation.
| #endif | ||
| #if AXIS_DRIVER_TYPE(E4, TMC2130) | ||
| { constexpr int extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); } | ||
| { _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); } |
SUMMARY OF WARNINGS
DETAILED WARNINGS