title: Silent symbol collision?
body: <p>Posted on the Raspberry Stackexchange before, closed as off-topic, so here I am.</p>
  <p>The following program compiles cleanly with <code>gcc main.c -lpigpio -lpthread -Wall -Wextra</code>. I'm using gcc 8.3.0 (crosscompiler or normal compiler doesn't change anything).</p>
  <pre><code>// main.c
  #include &lt;stdio.h&gt;
  #include &lt;pigpio.h&gt;
  
  void listen() {
          printf(&quot;hi from listen\n&quot;);
  }
  
  int main() {
          gpioInitialise();
          printf(&quot;hi from main\n&quot;);
          gpioTerminate();
          return 0;
  }
  </code></pre>
  <p>No warnings, yet the program happily prints <br></p>
  <pre><code>hi from listen
  hi from main
  </code></pre>
  <p>The cause seems to be that <code>gpioInitialise()</code> tries to call listen(2) from <code>&lt;sys/sockets.h&gt;</code> <a href="https://github.com/joan2937/pigpio/blob/master/pigpio.c#L7209" rel="nofollow noreferrer">here</a>, but instead calls the function from <code>main.c</code>. Of course, this doesn't work and results in an error message from the pigpio library:</p>
  <pre><code>xxxx-xx-xx xx:xx:xx pthSocketThread: setsockopt() fail, closing socket -1
  xxxx-xx-xx xx:xx:xx pthSocketThread: accept failed (Bad file descriptor)
  </code></pre>
  <p>Question: How come that gcc links a function with a completly different signature without throwing any errors? I know about <code>static</code>, but I want to make sense of this to learn from it. Surely it can't be as simple as listen(2) not being declared as static?</p>