title: Confusion about redefining constant using define directive(#define) in C
body: <p>As far as I know, standard allows redefinition only if the new definition duplicates the old one. So for example, </p>
  
  <p>If,</p>
  
  <pre><code>#define X 100
  </code></pre>
  
  <p>Then, </p>
  
  <pre><code>#define X 200 // Not allowed
  #define X 100 // Allowed
  </code></pre>
  
  <p>But what confuses me is when the header file includes redefintion which doesn't duplicate the old defintion. For example, </p>
  
  <p>There is a header file, <code>header.h</code> such that</p>
  
  <pre><code>#ifndef X
  #define X 100
  #endif
  </code></pre>
  
  <p>and source code <code>main.c</code> such that </p>
  
  <pre><code>#define X 10
  #include "header.h" 
  </code></pre>
  
  <p>Since <code>#define X 100</code> is below <code>#define X 10</code> in the <code>main</code> file, I thought this would occur error. But surprisingly, the compiler does not complain! Why is such behaviour allowed in C?</p>