Implementing callback functions in C
Posted
by robertjohn123
on Stack Overflow
See other posts from Stack Overflow
or by robertjohn123
Published on 2010-04-29T15:11:29Z
Indexed on
2010/04/29
15:17 UTC
Read the original article
Hit count: 280
Filed under:
c
Hi,
I am a newbie to C.I am trying to implement callback function using function pointers.
I am getting an error
:test_callback.c:10: error: expected identifier or ‘(’ before ‘void’
when I try to compile the following program:
#include<stdio.h>
void (*callback) (void);
void callback_proc ()
{
printf ("Inside callback funtion\n");
}
void register ((void (*callback) (void)))
{
printf ("Inside registration \n");
callback (); /* Calling an initial callback with function pointer */
}
int main ()
{
callback = callback_proc;/* Assigning function to the function pointer */
register (callback);/* Passing the function pointer */
return 0;
}
What is this error?Can anyone help?
© Stack Overflow or respective owner