title: Why do I get "conflicting declaration" error using two and more typedef-based static asserts with gcc and template function?
body: <p>I have the following code (no, the template is not instantiated anywhere):</p>
  
  <pre><code>#define cAssert( expr ) typedef char __C_ASSERT__[( expr )?1:-1]
  
  template&lt;int t&gt;
  void f()
  {  
     cAssert( t != 0 );
     cAssert( t != 2 );
  }
  </code></pre>
  
  <p>which compiles just fine with Visual C++ (when <code>t</code> is neither 0 nor 2 of course). Yet gcc (4.9.0 and earlier - you can test them on <a href="http://gcc.godbolt.org/" rel="nofollow">http://gcc.godbolt.org/</a>) outputs this:</p>
  
  <pre><code>In function ‘void f()’:
  1 : error: conflicting declaration ‘typedef char __C_ASSERT__ [((t != 2) ? 1 : (-1))]’
  #define cAssert( expr ) typedef char __C_ASSERT__[( expr )?1:-1]
  </code></pre>
  
  <p>If I only leave a single <code>cAssert()</code> (any of the two) - it compiles fine. The problem is there only when I have both of them.</p>
  
  <p>Why would gcc reject this code and how can I fix this?</p>