LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

calling function with function like parameters

Hi guys,
is it possible in CVI make somthings like this ???
I'd like call functB with address of functA like parameter

file A
--------------------------------
int functA (int param1)
{
....
return i
}
---------------------------------


file B
---------------------------------
void functB ( int *functA)
{
....
i=functA(x);
}
---------------------------------

Thank's for your help

Marco


0 Kudos
Message 1 of 4
(3,004 Views)
Yes, this is possible in C using function pointers. For example:

void functB ( int (*)(int) f)
{
.....
i = f(x);
....
}

You will call functB as:
functB (functA);
OR
functB (&functA);
Both the above are equivalent. Refer to any good C book for function pointer declarations.
0 Kudos
Message 2 of 4
(2,978 Views)
Correction:

functB should be:

void functB (int (*f) (int)
{
....
i = f(x);
....
}
0 Kudos
Message 3 of 4
(2,977 Views)
Hi Marco,
have you already tried this with other compilers?
 
CVI is an ANSI C based programming interface, therefore if you can do it with other C compilers you shoud be able to do it in CVI.
Is there any particular issue you want to verify?
 
 
Thanx and...Happy New Year!
 
RaffaL
0 Kudos
Message 4 of 4
(2,975 Views)