Is there a way not to open the unused parameter warning?

Asked 2 years ago, Updated 2 years ago, 125 views

Is there a way to prevent the unused parameter warning from appearing on the C code? For example,

Bool NullFunc(const struct timespec *when, const char *who, unsigned short format, void *data, int len)
{
   return TRUE;
}

In C++, /.../ could be used in the parameter to annotate C says error: parameter name selected -,-

Please don't let this pop up

gcc c warning

2022-09-22 15:52

1 Answers

You don't want to erase unused parameters? Then we usually use macros to process it.

#define UNUSED(x) (void)(x)

For example:

void f(int x) {
    UNUSED(x);
    ...
}


2022-09-22 15:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.