title: Why implicit declaration of pthread_yield with -lpthread while all ok with -pthread?
body: <p>I compile this code main.c in CentOS7 with gcc:</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  void* mystart(void* arg)
  {
      pthread_yield();
      return(0);
  }
  int main(void)
  {
      pthread_t pid;
      pthread_create(&amp;pid, 0, mystart, 0);
      return(0);
  }
  </code></pre>
  
  <p>1st compile: <code>gcc -Wall -g main.c -pthread -o a.out</code><br>
  It's all OK.</p>
  
  <p>2nd compile: <code>gcc -Wall -g main.c -lpthread -o a.out</code><br>
  Gives</p>
  
  <blockquote>
    <p>warning: implicit declaration of function 'pthread_yield' [-Wimplicit-function-declaration]</p>
  </blockquote>
  
  <ol>
  <li>Can the 2nd <code>a.out</code> still run correctly ?</li>
  <li>How to fix the warning without <code>-pthread</code>? Is <code>sched_yield</code> another way to yield a pthread ?</li>
  </ol>