Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Using C signal handler in my class

Reply
Thread Tools

Using C signal handler in my class

 
 
Ben
Guest
Posts: n/a
 
      10-19-2007
The signal() is the one in signal.h (csignal), in my class I defined a
SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
myHandler), but the compiler gave me the error:
error: argument of type 'void (myClass:(int)' does not match 'void
(*)(int)'
Where have I done wrong?

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      10-19-2007
Ben wrote:
> The signal() is the one in signal.h (csignal), in my class I defined a
> SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
> myHandler), but the compiler gave me the error:
> error: argument of type 'void (myClass:(int)' does not match 'void
> (*)(int)'
> Where have I done wrong?


You've not read the FAQ before posting. Search for "callback" in
the FAQ, it should hopefully clear some stuff up.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      10-19-2007
On Oct 20, 7:53 am, "Victor Bazarov" <(E-Mail Removed)> wrote:
> Ben wrote:
> > The signal() is the one in signal.h (csignal), in my class I defined a
> > SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
> > myHandler), but the compiler gave me the error:
> > error: argument of type 'void (myClass:(int)' does not match 'void
> > (*)(int)'
> > Where have I done wrong?

>
> You've not read the FAQ before posting. Search for "callback" in
> the FAQ, it should hopefully clear some stuff up.
>
> V

Thanks, V. Just wondering is there a direct link to the FAQ? I found
it using search.


 
Reply With Quote
 
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
Posts: n/a
 
      10-19-2007
On 2007-10-19 23:07, Ben wrote:
> The signal() is the one in signal.h (csignal), in my class I defined a
> SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
> myHandler), but the compiler gave me the error:
> error: argument of type 'void (myClass:(int)' does not match 'void
> (*)(int)'
> Where have I done wrong?


signal() expects a function pointer and not a member function pointer.
You can not have a member function as a callback for C functions, only
plain functions will work.

--
Erik Wikström
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      10-19-2007
Erik Wikström wrote:
> On 2007-10-19 23:07, Ben wrote:
>> The signal() is the one in signal.h (csignal), in my class I defined a
>> SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
>> myHandler), but the compiler gave me the error:
>> error: argument of type 'void (myClass:(int)' does not match 'void
>> (*)(int)'
>> Where have I done wrong?

>
> signal() expects a function pointer and not a member function pointer.
> You can not have a member function as a callback for C functions, only
> plain functions will work.
>

Plain functions with extern "C" linkage.

--
Ian Collins.
 
Reply With Quote
 
Ben
Guest
Posts: n/a
 
      10-19-2007
On Oct 20, 8:48 am, Ian Collins <(E-Mail Removed)> wrote:
> Erik Wikstrm wrote:
> > On 2007-10-19 23:07, Ben wrote:
> >> The signal() is the one in signal.h (csignal), in my class I defined a
> >> SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
> >> myHandler), but the compiler gave me the error:
> >> error: argument of type 'void (myClass:(int)' does not match 'void
> >> (*)(int)'
> >> Where have I done wrong?

>
> > signal() expects a function pointer and not a member function pointer.
> > You can not have a member function as a callback for C functions, only
> > plain functions will work.

>
> Plain functions with extern "C" linkage.
>
> --
> Ian Collins.


Speaking of extern linkage, do I need to apply this to those c headers
like "unistd.h", "fcntl.h"?

 
Reply With Quote
 
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
Posts: n/a
 
      10-20-2007
On 2007-10-20 00:32, Ben wrote:
> On Oct 20, 7:53 am, "Victor Bazarov" <(E-Mail Removed)> wrote:
>> Ben wrote:
>> > The signal() is the one in signal.h (csignal), in my class I defined a
>> > SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
>> > myHandler), but the compiler gave me the error:
>> > error: argument of type 'void (myClass:(int)' does not match 'void
>> > (*)(int)'
>> > Where have I done wrong?

>>
>> You've not read the FAQ before posting. Search for "callback" in
>> the FAQ, it should hopefully clear some stuff up.
>>
>> V

> Thanks, V. Just wondering is there a direct link to the FAQ? I found
> it using search.


Normally the FAQ can be found at www.parashift.com but it seems to be
down at the moment, till it comes up again use the copy at
http://www.coders2020.com/cplusplus-...ned/index.html

--
Erik Wikström
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      10-20-2007
Ben wrote:
> On Oct 20, 8:48 am, Ian Collins <(E-Mail Removed)> wrote:
>> Erik Wikstrm wrote:
>>> On 2007-10-19 23:07, Ben wrote:
>>>> The signal() is the one in signal.h (csignal), in my class I defined a
>>>> SIGALRM handler and then in my constructor I wrote signal(SIGALRM,
>>>> myHandler), but the compiler gave me the error:
>>>> error: argument of type 'void (myClass:(int)' does not match 'void
>>>> (*)(int)'
>>>> Where have I done wrong?
>>> signal() expects a function pointer and not a member function pointer.
>>> You can not have a member function as a callback for C functions, only
>>> plain functions will work.

>> Plain functions with extern "C" linkage.
>>

*Please* don't quote signatures.
>
> Speaking of extern linkage, do I need to apply this to those c headers
> like "unistd.h", "fcntl.h"?
>

No, they will have their own C++ wrappers.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does a handler render the request to another handler in the MVC of SPRING 2.0.1 framework? rayzyang@gmail.com Java 0 05-30-2007 11:28 AM
Event Handler that creates adds another event handler kaczmar2@gmail.com ASP .Net 1 02-22-2007 07:37 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
using filedescriptors in SIGINT signal handler Bram Stolk Python 2 09-13-2005 02:01 PM
Using Signal Handler to timeout an rsh call rh0dium Python 0 08-22-2005 02:07 PM



Advertisments