Function pointers - outside library, warning: initialization from
incompatible pointer type
With yours help I finally compiled a code with function pointers. But now
I would like to do exact same thing but for functions which are from the
"outside" library. typedef, arguments, compilation flags are 100% fine, I
got this warning ONLY when I try to call a function from the outside
library (when I wrote a function with the same prototype and tried to call
it with this code it was just fine). Any ideas?
#include <stdio.h>
#include <stdlib.h>
#include "libs/outlib.h"
typedef int (*VFUNCV)(int, double);
void call(int which, VFUNCV* fun, int a, double b)
{
fun[which](a, b);
}
int main()
{
VFUNCV fun[2] = {outlibfun1, outlibfun2};
call(0, fun, 3, 4.5);
return 0;
}
Warning:
funargs.c: In function 'main':
funargs.c:14:5: warning: initialization from incompatible pointer type
[enabled by default]
funargs.c:14:5: warning: (near initialization for 'fun[0]') [enabled by
default]
funargs.c:14:5: warning: initialization from incompatible pointer type
[enabled by default]
funargs.c:14:5: warning: (near initialization for 'fun[1]') [enabled by
default]
And 14th line:
VFUNCV fun[2] = {outlibfun1, outlibfun2};
No comments:
Post a Comment