title: How to prevent multiple definitions in C?
body: <p>I'm a C newbie and I was just trying to write a console application with Code::Blocks. Here's the (simplified) code:
  main.c:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "test.c" // include not necessary for error in Code::Blocks
  
  int main()
  {
      //t = test(); // calling of method also not necessary
      return 0;
  }
  </code></pre>
  
  <p>test.c:</p>
  
  <pre><code>void test() {}
  </code></pre>
  
  <p>When I try to build this program, it gives the following errors:</p>
  
  <pre>
  *path*\test.c|1|multiple definition of `_ test'|
  obj\Debug\main.o:*path*\test.c|1|first defined here|
  </pre>
  
  <p>There is no way that I'm multiply defining test (although I don't know where the underscore is coming from) and it seems highly unlikely that the definition is somehow included twice. This is all the code there is.</p>
  
  <p>I've ruled out that this error is due to some naming conflict with other functions or files being called test or test.c. Note that the multiple and the first definition are on the same line in the same file.</p>
  
  <p>Does anyone know what is causing this and what I can do about it? Thanks!</p>