原文地址:http://www.cnblogs.com/mlj318/archive/2011/11/02/2233106.html
在VC 6.0 环境中调试程序出现错误
error C2440: 'initializing' : cannot convert from '' to 'void (__cdecl *)(int,int,...)'
None of the functions with this name in scope match the target type
将PF pfun = add; 修正为 PF pfun = (void (__cdecl *)(int,int,...))add;
修正结果为下面代码中显示:
#include <stdio.h>
#include <stdlib.h>
typedef void (* PF)(int,int,...);
void add(int a,int b,int *result)
{
*result=a+b;
printf("result:%d\n",*result);
}
void main()
{
int x,y,z;
PF pfun = (void (__cdecl *)(int,int,...))add;
x=5;
y=4;
pfun(x,y,&z);
}
在VC6.0环境中调试程序时遇到errorC2440错误,通过修改函数指针定义方式成功解决问题。具体操作包括:将PFpfun=add;修正为PFpfun=(void(__cdecl*)(int,int,...))add;,并实现了一个简单的add函数,用于演示如何正确定义和使用函数指针。
2608

被折叠的 条评论
为什么被折叠?



