title: parse C header file to determine all defined macros
body: <p>I want to parse header file to fetch all constant macros like:</p>
  
  <pre><code>#define ARRSIZE 10
  #define WORDSIZE 32
  #define TOTALSIZE (ARRSIZE * WORDSIZE)
  </code></pre>
  
  <p>And create a list and an array such as:</p>
  
  <pre><code># define XARRSIZE 0
  # define XWORDSIZE 1
  # define XTOTALSIZE 2
  
  int table[] = {ARRSIZE, WORDSIZE, TOTALSIZE}
  // Now, table[XWORDSIZE] will fetch value of WORDSIZE.
  </code></pre>
  
  <p>So, I want to ignore the following:</p>
  
  <ol>
  <li>All comments.</li>
  <li>Structure (C <code>struct</code>) declarations.</li>
  <li><code>extern</code> function declarations.</li>
  <li><code>typedef</code>s.</li>
  </ol>
  
  <p>An approach can be write a parser using lex and yacc. But, this task seems much simpler. Is there a way to iterate over all constant macros in header file using tool such as 'cpp'?</p>
  
  <p>Please suggest any better approach.</p>