0
votes


In my A.h file
Node RemoveString(Node (*)(char,Node));
Node Minimum(char, Node);


In my A.c file
Node Minimum(char type, Node node) {......}
Node RemoveString(Node(*Minimum)(char, Node)) {...}


In my B.h file
void Test_Function(Node (*)(char,Node));


In my B.c file
void Test_Function(Node(*Minimum)(char, Node)) {...}


In my Main.c
Test_Function(Node(*Minimum)(char, Node));//This line has error.


Node is defined in A.h
B.h include "A.h"
Main.c include "B.h"


The compiler complains that error: expected expression before ‘Node’
Can anybody tell me why ?What i did wrong in this case?

3
Try Test_Function(&Minimum);Timo

3 Answers

4
votes

When you call a function, you just use the name of the function rather than the complete definition again. So this line:

Test_Function(Node(*Minimum)(char, Node));

Should be:

Test_Function(&Minimum);

Of course you should also make sure that the functions Test_Function and Minimum are defined (i.e. files included) before this statement.

1
votes

The expression you are using as Test_Function argument is a type, not a function pointer. The function pointer is just the function's name:

Test_Function(Minimum);
0
votes

You tagged this c, so I take it you're using a C compiler (not C++) -- right? In that case you need to either write struct Node in each declaration, or use a typedef.