Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Continued from the comments above...</p> <p>(1) The <code>pthread_create</code> start function (3rd parameter) <em>must</em> have a signature of </p> <pre><code>void *(*start_routine) (void *) </code></pre> <p>that is, a function that takes a void pointer and returns a void pointer. For example:</p> <pre><code>void* myfunc(void *) </code></pre> <p>You are getting compile errors because your start function probably (and incorrectly) looks like this:</p> <pre><code>void myfunc(void) </code></pre> <p>in other words a function that takes <em>no</em> parameters and returns no result. You got around this compiler error by casting myfunc to a pointer to void but it is unnecessary and wrong. Your real problem is that your start function "myfunc" has the wrong signature.</p> <p>(2) It seems you are hung up on void and pointers to void. There several good answers here on this including <a href="https://stackoverflow.com/questions/11626786/what-does-void-mean-and-how-to-use-it">this</a>. Basically a pointer to void is a generic pointer that can point to <em>any</em> type. </p> <p><code>pthread_create</code> is itself an excellent example of the use of void ptrs. Because there is no way for a start function to know what kind of data a developer wants to pass into (and return) from the function they use a void ptr that can point to any type. It is up to the developer of the start function to then cast the void ptr to appropriate type he actually passed before using whatever the void ptr points to. So now the start function can process a ptr that may in actually point to an int, a double, an array, a structure, or whatever.</p> <p>In your case you are turning a pointer to a function with a specific signature into a pointer to anything. This may satisfy the compiler because it assumes you know what you are doing. But in this instance you don't because you are papering over the real error which is that the signature of your start function is wrong. </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.
 

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