问题
Please explain me where I am wrong. I want to switch between several encoding utilities using pointer to function. I declare it like
int (*enc_routine)();
Later I switch coding utilities like
enc_routine = g723_24_encoder;
where utility by itself is something like
extern int g723_24_encoder(
int sample,
int in_coding,
struct g72x_state *state_ptr);
Everything was cute and fine on Linux, but now I am on Visual Studio 2012 and it says:
a value of type "int (*)(int sample, int in_coding, g72x_state *state_ptr)" cannot be assigned to an entity of type "int (*)()"
Thank you for help (if any)!
回答1:
You need to declare the parameters for your function pointer. You can't declare it to take no parameters and set it equal to a function that requires 3 parameters. I'm shocked it worked on linux.
来源:https://stackoverflow.com/questions/15653604/function-pointer-in-visual-studio-2012