Newsgroups: comp.lang.c++
Path: utzoo!utgpu!cunews!csi.uottawa.ca!news
From: hitz@sim5.csi.uottawa.ca (Martin Hitz)
Subject: Re: signal in C++
Message-ID: <1991Apr25.160506.8896@csi.uottawa.ca>
Keywords: signal
Sender: news@csi.uottawa.ca
Nntp-Posting-Host: sim5
Organization: University of Ottawa
References: <6476@male.EBay.Sun.COM>
Distribution: na
Date: Thu, 25 Apr 91 16:05:06 GMT

In article <6476@male.EBay.Sun.COM> chrisdc@mykids.EBay.Sun.COM (chris chang) writes:
>
>I am having a problem with using signal in C++.  I get a undefined 
>symbol error message for '_signal__FiPFv_v' when I link the program.
>Any ideas?  Also, what's the proper way to declare a function 
>prototype for signal?

The answer to question no. 2 is the answer to question no 1:

extern "C" void (*signal(int sig, void (*func)()))();


To find the answer yourself, follow this procedure:

1) man signal
   This displays the synopsis (for C):
   
	void (*signal(sig, func))()
	void (*func)();

2) Start your protoytpe with

	extern "C"
	
   followed by the main synopsis for signal and a semicolon, yielding
   
   	extern "C" void (*signal(sig, func))();

3) Expand the formal parameter names to parameter prototypes; if no type
   is given, use 'int'. In this example, replace 'func' with its
   declaration. In some complicated cases, this step might cause the
   algorithm to become recursive.
   
However, if you don't care to be type save, you might want to use the
shorthand:

extern "C" void (*signal(...))();

Regards,
	Martin (hitz@csi.UOttawa.CA)
