By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

question about function pointer

P: n/a
Hi all

passing argument of "lib_init_terminal" from incompatible pointer type

invoke code slice
=================
lib_init_terminal (&sys_init_signals);
prototype
=========
void sys_init_signals (void);
int lib_init_terminal (void *ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals)();
}

where 's the mistake?


thank you very much

your key9
Sep 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
key9 wrote:
Hi all

passing argument of "lib_init_terminal" from incompatible pointer type

invoke code slice
=================
lib_init_terminal (&sys_init_signals);
prototype
=========
void sys_init_signals (void);
int lib_init_terminal (void *ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals)();
}

where 's the mistake?
Why is it so hard for people to post compilable code? Surrounding your
call with 'int main(void) {' and '}' would have been easier for you that
those stupid tags with equal-sign underlining.

The answer:

void sys_init_signals(void);

#if 0
/* your illegal form, which claims ptr_sys_init_signals returns
a pointer-to-void */
int lib_init_terminal(void *ptr_sys_init_signals(void))

/* a form that works */
int lib_init_terminal(void (*ptr_sys_init_signals) (void))
#endif
/* and a cleaner form that works */
int lib_init_terminal(void ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals) ();
return 0; /* added. You claim lib_init_terminal
returns an int, but you don't return
one. */
}

int main(void)
{
lib_init_terminal(&sys_init_signals);
return 0;
}
Sep 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.