help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with signal() please


From: Steven Schaefer
Subject: Re: help with signal() please
Date: Tue, 16 Jul 2002 10:16:00 -0400

Hmm, I guess I still am part of the list.
Thanks Jeremy, that worked. I guess I never thought that a function prototype could specify it's argument's argument... yeah I said that correctly. -Steve jeremyl@accelrys.com writes:
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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]