The question was probably meant to be about why it's used, and that's already been answered. I'm going to talk about what it means (which the OP probably already knows, but others may not). At least one other question has been closed as a duplicate of this one.
In general, casting an expression to void
evaluates the expression and discards the result, if any. In this case, the expression is c
, the name of a variable of type task_cleanup
(whatever that is).
An expression followed by a semicolon is an expression statement. When the statement is executed, the expression is evaluated and its result is discarded.
So this:
(void)c;
evaluates c
(which, since c
is just a non-volatile declared object, just fetches the value of the object), then discards the result, then discards the result again.
Semantically, this doesn't make much sense. You might as well just write:
c;
or even omit it entirely with exactly the same effect.
The purpose, as the other answers have already said, is to suppress a warning that the variable's value is not used. Without the cast, many compilers will warn that the result is discarded. With the cast, most compilers will assume that you're deliberately discarding the value, and will not warn about it.
This is no guarantee; compilers can warn about anything they like. But casting to void
is a sufficiently widespread convention that most compilers will not issue a warning.
It probably would have been worthwhile to call the variable ignored
rather than c
, and a comment would definitely be helpful.