Here is my collection of function prototypes for
function, gleaned from a number of different operating systems.
The UNIX 'signal' function lets you tell the OS which function will handle which signal. You call it like this...
signal ( signal_name, signal_handler ) ;The signal_handler function (that you have to provide) typically needs no parameters. The issue here is how do you write the 'signal_handler' function so that it's address can be passed to the 'signal' function.
void signal_handler() ;
void signal_handler( int, ... ) ;
void signal_handler( ... ) ;
void signal_handler( int ) ;
extern "C" void signal_handler ( int ) ;
typedef void (*__sighandler_t)(int); __sighandler_t signal_handler ;This is clearly just a pathetic attempt to be different from IRIX 6.2 - but you can't really expect a bunch of enthusiastic amateurs to remain totally incompatable across four generations of operating systems.
typedef void (*__sighandler_t) __P ((int)); __sighandler_t signal_handler ;Well, you can imagine my joy on unwrapping my SuSE Linux 6.1 and finding an __P in there! The double brackets around the 'int' was just icing on the cake really.
void (*signal_handler)(int)...but just as you drift back nostagically to the days when you could understand this stuff, they add the immortal line:
"If you're confused by the prototype at the top of this manpage, it may help to see it separated out thus: typedef void (*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler);Mmmm'K.
But not to worry, after a quick rummage in the header file, the true horror is revealed:
typedef void (*__sighandler_t) __PMT ((int)); __sighandler_t signal_handler ;Yep - thought so!
If you have any other examples you can email me at: firstname.lastname@example.org