title: C style/C++ correctness, is struct/union/enum tag same as type name bad in any way?
body: <p>The following definition of MyStruct (tag MyStruct) and type definition of type MyStruct seems  perfectly compillable by gcc (at least 4.6.2) and by g++.</p>
  <pre><code>typedef struct MyStruct {
    int a;
    int b;
  } MyStruct;
  </code></pre>
  <p><strong>My question is: is it somehow error-prone (in C and/or C++) or bad style to use tag name the same as the type name?</strong></p>
  <p>According to <a href="http://www.eetimes.com/discussion/programming-pointers/4024450/Tag-vs-Type-Names" rel="noreferrer">http://www.eetimes.com/discussion/programming-pointers/4024450/Tag-vs-Type-Names</a> it is not:</p>
  <blockquote>
  <p>I've never understood why they use different names for the tag and the typedef when one name will do just fine:</p>
  <pre><code>typedef struct tree_node tree_node;
  </code></pre>
  </blockquote>
  <p>But often I've seen code styled like:</p>
  <ol>
  <li><code>typedef struct tagMyStruct {...} MyStruct;</code></li>
  <li>typedef struct myStruct {...} MyStruct;`</li>
  <li><code>typedef struct _MyStruct {...} MyStruct;</code> &lt; yes, I know about underscore + capital letter</li>
  </ol>
  <p>In each case someone went to some extent to make tag name <em>differ</em> from type name. Are there any practical reasons behind it?</p>
  <p>Side note: I use C++ compiler but I would like to be C compatible with those definitions (I know this is bad style for c++). For reasons of maintaining usability of some debug tools, I need all the tag names to be meaningful (not the automatically generated __unknown_something tags in case of unnamed structs you can, for example, see in visual studio class view).</p>
  <p>Same issue/question apply to unions and enums.</p>