title: #define and #include order in C
body: <p>I've following code which I compile with <code>gcc</code></p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdbool.h&gt;
  #define true 9
  int main() { 
     printf("TRUE = %d\n",true);
     return 0;
  }
  </code></pre>
  
  <p>And I get Error</p>
  
  <pre><code>test.c:3:0: warning: "true" redefined [enabled by default]
  In file included from test.c:2:0:
  /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdbool.h:34:0: note: this is the location of the previous definition
  </code></pre>
  
  <p>But when I alter the code a bit    </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #define true 9
  #include&lt;stdbool.h&gt;
  int main() { 
     printf("TRUE = %d\n",true);
     return 0;
  }
  </code></pre>
  
  <p>Output:    </p>
  
  <pre><code>TRUE = 1
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>I understand the reason for error in first case but In second case when I define <code>true</code> before I <code>#include&lt;stdbool.h&gt;</code>, why is it allowed to redefine <code>true</code>?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Here is <a href="https://gist.github.com/TheKojuEffect/6669422" rel="nofollow noreferrer">stdbool.h</a>.</p>
  
  <p>First few lines are </p>
  
  <pre><code>#ifndef _STDBOOL_H
  #define _STDBOOL_H
  
  #ifndef __cplusplus
  
  #define bool    _Bool
  #define true    1
  #define false   0
  </code></pre>
  
  <p>which is nothing like in the Yu Hao 's <a href="https://stackoverflow.com/a/18958248/1433665">answer</a> .</p>