本文介绍了Visual Studio 2012中的函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请向我解释我哪里错了.我想使用函数指针在多个编码实用程序之间切换.我这样声明

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);

在Linux上,一切都很不错,但是现在我在Visual Studio 2012上,它说:

Everything was cute and fine on Linux, but now I am on Visual Studio 2012 and it says:

感谢您的帮助(如果有的话)!

Thank you for help (if any)!

推荐答案

您需要为函数指针声明参数.您不能声明它不带任何参数并将其设置为等于需要3个参数的函数.我很震惊它可以在linux上运行.

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.

这篇关于Visual Studio 2012中的函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:14