Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointer to a function

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello, i try to use the clone function because i want my two processes to share data. Unfortunatelly, whatever i do, the compiler tells me:

passing arg 1 of `clone' from incompatible pointer type

The man page of clone is:

int clone(int (*fn)(void *), void *child_stack, int flags,
void *arg);

So "fn" IS A POINTER TO A FUNCTION, so i tried this:

int (*pf)(int);
pf=&my_function;
clone(&pf,...);

I also tried clone(pf,...);clone(*pf,...);...very bad things
And i'm always said the same thing!

Thanks for your help.

thomas
 
Your function must be a
Code:
int (*fn)(void *)
not a
Code:
int (*fn)(int);

Try:
Code:
int (*pf)(void *);
pf=&my_function;
clone(pf,...);
Of course my_function must also take a void * as argument and not an int.

You could also use the simple form:
Code:
clone(my_function, ...);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top