title: Why does gcc produce an error for implicit declaration of functions returning not int?
body: <p>There are a few similar questions asking people to debug their code, where the compiler produces a warning of implicit declaration of functions. I know that this warning is produced because if a function is used without there being a prior declaration, function calls can be treated as implicit declarations.</p>
  
  <p>This code has an <em>intentional</em> bug for educational purposes.
  There are two implicitly declared functions here: one returns <code>int</code>, the second function returns <strong>another data type</strong> which is <code>char*</code>.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      function1();
      function2();
  }
  
  int function1(void)
  {
      printf("function1\n");
      return 2;
  }
  
  char* function2(void)
  {
      char* word = "function2\n";
      printf(word);
      return word;
  }
  
  </code></pre>
  
  <p>When I go to compile this code, I get these warnings, and an <strong>error</strong>:</p>
  
  <pre><code>$ gcc test1.c
  test1.c: In function ‘main’:
  test1.c:5:5: warning: implicit declaration of function ‘function1’ [-Wimplicit-function-declaration]
       function1();
       ^
  test1.c:6:5: warning: implicit declaration of function ‘function2’ [-Wimplicit-function-declaration]
       function2();
       ^
  test1.c: At top level:
  test1.c:15:7: error: conflicting types for ‘function2’
   char* function2(void)
         ^
  test1.c:6:5: note: previous implicit declaration of ‘function2’ was here
       function2();
       ^
  
  </code></pre>
  
  <p>First I created the <code>function1</code> and I was able to compile and run the code without problems. The implicit declaration of <code>int function1()</code> was accepted, even though the compiler produced some warnings.</p>
  
  <p>Then I created the <code>function2</code> and to my surprise, an <strong>error</strong> was produced by the compiler and the code rejected. Why was the implicit declaration of <code>char* function2()</code> not accepted? Why didn't the function call as an implicit declaration work?</p>
  
  <p>This is the error:</p>
  
  <pre><code>error: conflicting types for ‘function2’
  </code></pre>
  
  <p>What is the conflicting type? There is only one type. The function takes no arguments and returns <code>char*</code>.</p>
  
  <p>Why did it work for <code>function1</code>?</p>