Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>void (*signal(int signo, void (*func)(int)))(int); </code></pre> <p>signal is function that takes int and a pointer to function taking int and returning void and returns a function pointer taking int and returning void. That is,</p> <pre><code>typedef void(*funcPtr)(int) </code></pre> <p>then we have</p> <pre><code>funcPtr signal(int signo, funcPtr func); //equivalent to the above </code></pre> <p>The syntax is indeed strange, and such things better be done with a typedef. As an example, if you want to declare a function that takes an int and returns a pointer to a function taking char and returning double will be</p> <pre><code>double (*f(int))(char); </code></pre> <p><strong>Edit:</strong> after a comment that reads "Wooooooow", I am providing another example which is more "woooow" :)</p> <p>Let's declare a function that takes<br> 1. a pointer to array of 5 pointers to functions each taking float and returning double.<br> 2. a pointer to array of 3 ponters to arrays of 4 ints<br> and returns a pointer to function that takes a pointer to function taking int and returning a pointer to function taking float and returning void and returns unsigned int. </p> <p>The typedef solution would be this:</p> <pre><code>typedef double (*f1ptr) (float); typedef f1ptr (*arr1ptr)[5]; typedef int (*arr2ptr)[4]; typedef arr2ptr (*arr3ptr)[3]; typedef void(*f2Ptr)(float); typedef f2ptr (*f3ptr)(int); typedef unsigned int (*f4ptr) (f3ptr); f4ptr TheFunction(arr1ptr arg1, arr3ptr arg2); </code></pre> <p>Now, the funny part :) <strong>Without typedefs this will be</strong>:</p> <pre><code> unsigned int (*TheFunction( double (*(*)[5])(float), int(*(*)[3])[4]))( void(*(*)(int))(float)) </code></pre> <p>My god, did I just write that? :)</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. 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