Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The second parameter of signal should be a pointer to a function accepting an int and returning void. What you're passing to signal is a pointer to a <em>member</em> function accepting an int and returning void (its type being <code>void (myClass::*)(int)</code>). I can see three possibilities to overcome this issue:</p> <p>1 - Your method <code>myHandler</code> can be static: this is great, make it static</p> <pre><code>class myClass { public: void myFunction () { signal(SIGIO, myClass::myHandler); } static void myHandler (int signum) { // handling code } }; </code></pre> <p>2 - Your method shouldn't be static: if you're planning to use signal with only one instance, you can create a private static object, and write a static method that simply call the method on this object. Something along the lines of</p> <pre><code>class myClass { public: void myFunction () { signal(SIGIO, myClass::static_myHandler); } void myHandler (int signum) { // handling code } static void static_myHandler(int signum) { instance.myHandler(signum); } private: static myClass instance; }; </code></pre> <p>3 - However, if you're planning on using the signal with multiple instances, things will get more complicated. Perhaps a solution would be to store each instance you want to manipulate in a static vector, and invoking the method on each of these :</p> <pre><code>class myClass { public: void myFunction () // registers a handler { instances.push_back(this); } void myHandler (int signum) { // handling code } static void callHandlers (int signum) // calls the handlers { std::for_each(instances.begin(), instances.end(), std::bind2nd(std::mem_fun(&amp;myClass::myHandler), signum)); } private: static std::vector&lt;myClass *&gt; instances; }; </code></pre> <p>and somewhere, do a single call to</p> <pre><code>signal(SIGIO, myClass::callHandlers); </code></pre> <p>But I think that if you end up using the last solution, you should probably think about changing your handling design :-)!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload