Say I have a function foo() which accepts a pointer to a void function as a parameter.
void foo(void (*bar)(int)) {
bar(5);
}
If I have a non-void function f(int)
bool f(int i) {
// ...
return true;
}
Is there a way to cast f in such a way that it can be passed to foo() without warnings?
My current solution is to define a function void g(int i) {f(i);} and pass g to foo, but this seems inefficient to me. It seems like there should be a way to cast f in such a way that its return value is thrown out.
If this isn't possible, why not?