I try to keep my code free of warnings even when using warning level 3. In my code there are some function pointers like typedef void (*fptr)(mytype*) but some of the functions defined with this signature do not need the parameter. Thus I used something like void f(mytype *x) { ... return; x; } to avoid the warning unused local. This worked fine with C compiler version up to 5.05 but gives warning C138: expression with possibly no effect in version 6.00. Any idea how to solve this?
This is an age-old problem - see http://www.keil.com/forum/docs/thread796.asp Note that even Stefan's suggestion of
x=x;
#pragma unused x
I'd suggest #define'ing a macro for unused arguments, so you can easily alter the definition to suit different compilers or optimization levels. My current definition for Keil, which generates no code or warnings at optimization levels 9 or 11, happens to be:
#define UNUSED(arg) if (arg) {} void f (U8* x, U16 y) { UNUSED(x); UNUSED(y); }
arg = arg if (0) { arg = arg; } (a) ((void)(a))
void f (U8* /* x */, U16 /* y */) { }
"... the new knowledgebase search function isn't finding anything for me ..." I am wondering whether the search facility has forgotten everything.
I am wondering whether the search facility has forgotten everything. Nope. We just reindexed everything this evening. This takes about 20 minutes. Jon
I'm now using
#define UNUSED_LOCAL(_l) ((_l)=(_l))