I have a member function in a class that has a callback, but the callback isn't strictly neccessary, so it has a default callback, which is empty. It seems to work fine, but I get an annoying warning:
warning: converting from ‘void (ClassName::*)()’ to ‘void (*)()’
I'm trying to figure out what it means and how to turn it off (or fix it if I really am doing something wrong). Here's some simple code:
class ClassName{
public:
void doSomething(void (*callbackFunction)() = (void(*)()) &ClassName::doNothing){
callbackFunction();
}
void doNothing(){}
};
int main(){
ClassName x;
x.doSomething();
return 0;
}
Note: If I do this (without explicitly casting it as a void(*)()
):
void doSomething(void (*callbackFunction)() = &ClassName::doNothing)
I get this:
main.cpp:3: error: default argument for parameter of type ‘void (*)()’ has type ‘void (ClassName::*)()’