Function pointer in Visual Studio 2012

那年仲夏 提交于 2020-01-06 08:08:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!