How to fix Keil EFM8 Warning C280: unreferenced local variable
Problem:
You have a C function like
myfunc.c
int myfunc(int value) {
return 0;
}but you see a Keil compiler warning like
keil-warning.txt
*** WARNING C280 IN LINE 7 OF C:\Users\uli\MyProject\src\main.c: 'value': unreferenced local variableSolution
'value': unreferenced local variable means that you don’t use that variable value in any way.
In the function shown above, you can see that value is the argument of myfunc but myfunc never actually uses the variable.
Do you think that variable should be used in this function?
You need to check your function for typos - the variable is never used at all. Possibly you are using the wrong variable or your function is missing some part of its logic.
Don’t want to use that variable at all?
Usually you can tell the compiler that you don’t want to use that variable by using
suppress-unused.c
(void)value;but that will produce an expression with possibly no effect warning.
keil-warning-expression.txt
*** WARNING C275 IN LINE 7 OF C:\Users\uli\MyProject\src\main.c: expression with possibly no effectYou can use this hack to avoid this warning:
avoid-unused.c
r = r; // Avoid unused local variable
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow