There are some c++ code
struct data {
/* some fields */
};
typedef struct data * pData;
int function(pData pointer) {
if(pointer == NULL)
return ERROR;
(void)pointer;
/* other work */
}
What does "(void)pointer" mean?
Just for your information, there are some int/char*/etc, some functions pointers which are used as callback functions in the structure.
It is used to circumvent an unused-variable warning.
If you do use the variable, it is a no-op.
Mostly unused variables are parameters, that are required to fulfil a signature for a callback function, but not needed in your actual implementation.
Cf.
-Wunused-variable
(enabled by -Wall
, too).Just because it was not mentioned otherwise: The type of the variable might be anything. It is not constricted to pointer types.
It doesn't mean a whole lot.
It evaluates the expression pointer
, then explicitly ignores it by casting it to void
.
Sometimes you see this construct when trying to convince a compiler not to warn for an un-used argument, but in your code the argument is already used since it's being NULL
-checked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With