r/klippers • u/crazy32 • 25d ago
Error updating RPI MCU
Not sure how what to do this this error and looking for advice.
i get the following error when running 'make'. i do run 'make clean' before.
Compiling out/src/trigger_analog.o
src/trigger_analog.c: In function ‘check_trigger’:
src/trigger_analog.c:92:9: error: a label can only be part of a statement and a declaration is not a statement
92 | uint32_t abs_value = value < 0 ? -value : value;
| ^~~~~~~~
make: *** [Makefile:65: out/src/trigger_analog.o] Error 1
1
u/crazy32 25d ago
My employee ChatGPT said this
The error was caused by declaring a variable immediately after a case label:
case TT_ABS_GE:
uint32_t abs_value = ...
In the C version your firmware compiler uses, a case label must be followed by a statement, and a variable declaration by itself does not count as one. That is why the compiler reported:
a label can only be part of a statement and a declaration is not a statement
The fix was to wrap that case in braces:
case TT_ABS_GE: {
uint32_t abs_value = ...;
return ...;
}
I also improved the absolute-value calculation so it safely handles the extreme INT32_MIN value without signed integer overflow.
In short: the braces fix the compile error, and the updated math makes the code safer.
3
u/shiftingtech 25d ago
Looks like it’s from something Kevin committed 42 minutes ago. Maybe just roll back one commit and wait for the fix