title: Implicit declaration of functions regardless of header include and ifndef
body: <p>I have the well-known errors :</p>
  
  <p><code>implicit declaration of function 'STLINKReadSytemCalls' [-Wimplicit-function-declaration]</code><br>
  <code>implicit declaration of function 'printf' [-Wimplicit-function-declaration]</code><br>
  <code>incompatible implicit declaration of built-in function 'printf'</code></p>
  
  <p>And Eclipse (Atollic TrueStudio more precisely) kindly added :</p>
  
  <p><code>include '&lt;stdio.h&gt;' or provide a declaration of 'printf'</code></p>
  
  <p>Reading the billions of post asking how to solve this problem on SO, it seems that three problems might cause these errors : </p>
  
  <ul>
  <li>Functions are defined after main;</li>
  <li>Required headers to use a function are included</li>
  <li><code>#ifndef</code>, <code>#define</code> and <code>#endif</code>do not correctly wrap the header files</li>
  </ul>
  
  <p>I have found a post in which someone seemed to have this error and said after fixing it that Eclipse was the problem. Can't find the topic though, but his solution didn't work for me. It was something like clicking on the function, <em>source</em> -> <em>add includes</em>.</p>
  
  <p><strong>main.c</strong></p>
  
  <pre><code>int main(void) {
  
      if (STLINKReadSytemCalls() == 1)
          printf("Error in system calls.\n");
      return 0;
  }
  </code></pre>
  
  <p><strong>fileProcessing.c</strong></p>
  
  <pre><code>#include "../header/fileProcessing.h"
  
  int STLINKReadSytemCalls(void) {
  
      // mainly system calls
  }
  </code></pre>
  
  <p><strong>fileProcessing.h</strong></p>
  
  <pre><code>#ifndef FILEPROCESSING_H_
  #define FILEPROCESSING_H_
  
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int STLINKReadSytemCalls(void);
  
  #endif /* FILEPROCESSING_H_ */
  </code></pre>
  
  <p>The most confusing part is that the code actually works. I have the following output : </p>
  
  <pre><code>STM32 ST-LINK CLI v3.0.0.0
  STM32 ST-LINK Command Line Interface
  
  No ST-LINK detected
  Unable to connect to ST-LINK!
  Error in system calls.
  </code></pre>
  
  <p>Everything seems to be fine, but compiler keeps yelling.
  I'll add the function's body if needed, but I have seen nowhere any clue telling that a function's body could cause an include error. I must be missing something so obvious that I'll self-facepalm like no one ever did when I'll see it; but I have already spent hours and my hope that this is obvious is getting thinner.</p>
  
  <p>Oh, and yesterday with the same include path and same directory build it worked perfectly fine. I really don't know what changed since. </p>