title: Why not concatenate C source files before compilation?
body: <p>I come from a scripting background and the preprocessor in C has always seemed ugly to me. None the less I have embraced it as I learn to write small C programs. I am only really using the preprocessor for including the standard libraries and header files I have written for my own functions.</p>
  
  <p>My question is why don't C programmers just skip all the includes and simply concatenate their C source files and then compile it? If you put all of your includes in one place you would only have to define what you need once, rather than in all your source files.</p>
  
  <p>Here's an example of what I'm describing. Here I have three files:</p>
  
  <pre><code>// includes.c
  #include &lt;stdio.h&gt;
  </code></pre>
  
  
  
  <pre><code>// main.c
  int main() {
      foo();
      printf("world\n");
      return 0;
  }
  </code></pre>
  
  
  
  <pre><code>// foo.c
  void foo() {
      printf("Hello ");
  }
  </code></pre>
  
  <p>By doing something like <code>cat *.c &gt; to_compile.c &amp;&amp; gcc -o myprogram to_compile.c</code> in my Makefile I can reduce the amount of code I write.</p>
  
  <p>This means that I don't have to write a header file for each function I create (because they're already in the main source file) and it also means I don't have to include the standard libraries in each file I create. This seems like a great idea to me!</p>
  
  <p>However I realise that C is a very mature programming language and I'm imagining that someone else a lot smarter than me has already had this idea and decided not to use it. Why not?</p>