I use Keil uVision to bulid a target there is no errors and warings.But Rebulid got 4 warinings,like: Warning C280: "ad_ ptr" unreferenced local variable
"So your choices are:"
Or, like I said,
4) Reference them. For example, the following works for many compilers.
static uint8_t ep_1_in_cb(uint8_t *adr_ptr, uint8_t* size) reentrant { (void)adr_ptr; (void)size; /* Reference unused parms */ ep1_sent = true; return 0x60; // NAK }
I included your alternative in my "use them".
But the important thing is that this is not Keil-specific. It is the same for just about all C/C++ compilers.
That's not quite the same as just referencing them.
"Use them" implies putting them to some functional use - whereas Dan's suggestion just references them without actually doing anything with them at all.
And there's the problem: some compilers will give a warning along the lines of "code has no effect" for such references...
:-(
BTW: Is it just me, or does the ARM compiler not warn about unused parameters?
It (4) works for many compilers but for C251 it just yields another warning.
The alternative (3) to just mention the type without a name also just yields another warning.
Whatever steps you try to avoid, finally you will have to #pragma warning disable _some_ warning, which looks very ugly in the code to do it locally.
Keil also has
__attribute__((unused)) variable