c++cunused-variables

How to supress unused (void **arg) parameter?


In the function below I'm not using the parameter (void **arg). But since it's unused inside the function compiler gives me the error below:

error: unused parameter 'arg' [-Werror=unused-parameter]
bool decodeString(pb_istream_t *stream, const pb_field_t *field, void **arg)

I tried to suppress it by writing void(arg) inside the function without any luck. Can anyone help me with the correct way?


Solution

  • Use the parameter in an expression casted to void. Then the parameter is "used".

    bool decodeString(pb_istream_t *stream, const pb_field_t *field, void **arg)
    {
        (void)arg;
        ...
    }