I still think you're confused. The parameter is of type "pointer to function", but what you pass needs to be the address of a function, just like in Windows. All I'm saying is that in C (on all platforms), for functions only, foo and &foo are equivalent. Both result in the address of the function named 'foo'. Try this in one of your Windows threading programs and let me know. Replace &foo with just foo, and see if it still works and calls the right function without any errors or warnings.
As a test, I compiled this in VC++ 2010 with warnings maxed out and got not a peep from the compiler:
Code:
#include <stdio.h>
void foo(int n)
{
printf("foo %d\n", n);
}
void bar(int n)
{
printf("bar %d\n", n);
}
void (*get_fn(int n))(int)
{
return n < 3 ? foo : &bar; // notice foo has no &, but bar does, and no type mismatch
}
int _tmain(int argc, _TCHAR* argv[])
{
int i;
void (*fn)(int);
for (i = 0; i < 10; i++) {
fn = get_fn(i);
fn(i);
}
return 0;
}