Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > question about function pointer

Reply
Thread Tools

question about function pointer

 
 
key9
Guest
Posts: n/a
 
      09-16-2006
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


 
Reply With Quote
 
 
 
 
Martin Ambuhl
Guest
Posts: n/a
 
      09-16-2006
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;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
diffrence between "function pointer" and "pointer to a function" murgan C Programming 6 12-21-2005 06:01 AM
Passing pointer to template function as argument to pointer to template function Vijai Kalyan C++ 4 11-08-2005 07:53 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM
pointer to member function and pointer to constant member function Fraser Ross C++ 4 08-14-2004 06:00 PM
function pointer and member function pointer question glen stark C++ 2 10-10-2003 01:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57