title: Include a file multiple times with different macros
body: <p>I got a file that contains generic methods for working with arrays of different number types (the basic ideas are described in <a href="https://stackoverflow.com/questions/16522341">Pseudo-generics in C</a>). The type can be specified by setting a <code>TYPE</code> macro. It looks like this (just a part of it):</p>
  
  <p><code>array_analyzers.c</code>:</p>
  
  <pre><code>#ifndef TYPE
  #error TYPE isn't defined
  #endif
  
  #define CONCAT(x, y) x ## y
  #define GET_NAME(BASE, TYPE) CONCAT(BASE, TYPE)
  
  TYPE GET_NAME(get_minimum_, TYPE) (TYPE nums[static 1], int len){
      TYPE min = nums[0];
  
      for (int i = 1; i &lt; len; i++) {
          if (nums[i] &lt; min) {
              min = nums[i];
          }
      }
  
      return min;
  }
  
  #undef CONCAT
  #undef GET_NAME
  #undef TYPE
  </code></pre>
  
  <p>Now, I created a header file that looks like this:</p>
  
  <p><code>array_analyzers.h</code>:</p>
  
  <pre><code>#ifndef TYPE
  #error TYPE isn't defined
  #endif
  
  #define CONCAT(x, y) x ## y
  #define GET_NAME(BASE, TYPE) CONCAT(BASE, TYPE)
  
  TYPE GET_NAME(get_minimum_, TYPE) (TYPE nums[static 1], int len);
  
  #undef CONCAT
  #undef GET_NAME
  #undef TYPE
  </code></pre>
  
  <p>Finally, I want to use this from <code>main.c</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #define TYPE int
  #include "array_analyzers.h"
  #define TYPE double
  #include "array_analyzers.h"
  
  int main(void){
    int nums[] = {1, 2, 3};
    printf("%i\n", get_minimum_int(nums, 3));
  }
  </code></pre>
  
  <p>However, I'm getting the following error message:</p>
  
  <pre><code>array_analyzers.c:2:2: error: #error TYPE isn't defined
  </code></pre>
  
  <p>What exactly is wrong here? It works when I run the preprocessor first and create separate files with the right contents, but that is just awful.</p>