Closed samuel-schuepbach closed 1 year ago
Hi Sam,
You apparently are using the -Werror
option that elevates warnings to errors. The parameter x
is, of course, used in this case (as register r0
per the AAPCS), but this is done inside the optimized assembly code, which the compiler does not analyze.
The preferred way to silence this warning (as in any other case of "unused parameters") is by means of the macro Q_UNUSED_PAR()
specially created for that, as follows:
__attribute__ ((naked, optimize("-fno-stack-protector")))
uint_fast8_t QF_qlog2(uint32_t x) {
Q_UNUSED_PAR(x);
__asm volatile ( . . .
This fix is already used in our internal version and will be included in the next release.
On a side note, I'm glad to see that you're using the QV kernel. This simple kernel is a good choice for a surprisingly wide range of applications.
--MMS
Thanks for the quick explanation with r0
, that absolutely makes sense.
I have changed my code locally the same way (with (void)(x);
for now, but that should do the same from what I can tell) and it works well. Happy to hear that it is already included!
I agree, QV is ideal for our use case. Its simple but does all that it needs to.
Thank you for the quick response and help. I will close the issue.
I am getting an error due to a unused parameter when compiling the arm-cm port with the gcc compiler (arm-none-eabi-gcc, 11.3.1)
It complains about the variable 'x' not being used in the following function:
If the variable is not used, it would be convenient to remove it or other wise suppress the error. Otherwise projects need to change the compiler flags to avoid this error or manually suppress the error in the code.