|
-
Jun 10th, 2004, 07:27 PM
#1
Thread Starter
Fanatic Member
Why these warnings?
I am practicing function pointers. Here's what I am doing: passing a function pointer to another function. It all goes well except for the two warnings I get:
[list=1][*]'ConsumeFnPointer' : too many actual parameters[*]declared formal parameter list different from definition[/list=1]
I am curious as to why I get those warnings. Can we not pass variable arguments to the right of the function pointer argument? Has it got something to do with the calling sequence (__stdcall, ___pascal etc.)?
Here's the code:
Code:
#include <stdio.h>
/*float Add(float, float);
float Subtract(float, float);
float Multiply(float, float);
float Divide(float, float);
float (*ptr)(float, float);
*/
int DoSomething(int, int);
int ConsumeFnPointer(int (*ptr1)(int, int));
int main()
{
//ptr=&Add;
//printf("%f",ptr(3,9));
printf("%d", ConsumeFnPointer(&DoSomething,12,4));
}
/*float Add(float a, float b) { return a+b;}
float Subtract(float a, float b){ return a-b;}
float Multiply(float a, float b){ return a*b;}
float Divide(float a, float b){ return a/b;}
*/
int ConsumeFnPointer(int (*ptr1)(int a, int b), int a, int b)
{
return (*ptr1)(a,b);
}
int DoSomething(int a, int b)
{
return 1+a-b;
}
-
Jun 11th, 2004, 02:53 AM
#2
The prototype and the definition of ConsumeFnPointer don't match.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 14th, 2004, 09:35 AM
#3
Thread Starter
Fanatic Member
Yup! Thanks! Just saw that a moment after making that post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|