Hi,
My man page describes the signature for a signal handler as a function
takin and int argument:
void ( * handler ) ( int );
Which seems to be what g++ is complaining about. The integer argument is
the signal.
try :
...includes...
#include <signal.h>
void SIGINT_signal_handler(int)
{
...some code...
}
int main( int argc, char argv[] )
{
/* TRIED A FUNCTION POINTER BUT IT DOESN'T SEEM TO DO ANY BETTER */
void (*function_pointer)(int);
function_pointer = SIGINT_signal_handler;
signal(SIGINT, function_pointer);
... other code ...
}
"Steven Schaefer" <mathews20@donet.com>
Sent by: help-gplusplus-admin@gnu.org
16/07/2002 13:33
To: help-gplusplus@gnu.org
cc:
Subject: help with signal() please
I don't know if I'm still part of the mail list so please CC me at
mathews20@donet.com, thanks in advance.
Every once in a while I run into a function that wants some type casting.
In my code, which I'm doing this under Linux:
...includes...
#include <signal.h>
void SIGINT_signal_handler(void)
{
...some code...
}
int main( int argc, char argv[] )
{
/* TRIED A FUNCTION POINTER BUT IT DOESN'T SEEM TO DO ANY BETTER
void (int *function_pointer)();
function_pointer = SIGINT_signal_handler;
*/
signal(SIGINT, function_pointer);
... other code ...
}
G++ when compiling says:
main.cpp: In function `int main(int, char *)':
main.cpp:137: passing `void (*)()' as argument 2 of `signal(int, void
(*)(int))'
make: *** [main.o] Error 1
How do I type cast this correctly? I've tried just about everyway I know
how.
_______________________________________________
Help-gplusplus mailing list
Help-gplusplus@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gplusplus