<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx</link><description>For consistent naming.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339842</link><pubDate>Thu, 27 Mar 2008 18:33:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339842</guid><dc:creator>Frederik Slijkerman</dc:creator><description>&lt;p&gt;And is there a reason not to use this?&lt;/p&gt;
&lt;p&gt;struct XYZ {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;...&lt;/p&gt;
&lt;p&gt;};&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339843</link><pubDate>Thu, 27 Mar 2008 18:33:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339843</guid><dc:creator>Frederik Slijkerman</dc:creator><description>&lt;p&gt;And is there a reason not to use this?&lt;/p&gt;
&lt;p&gt;struct XYZ {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;...&lt;/p&gt;
&lt;p&gt;};&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339844</link><pubDate>Thu, 27 Mar 2008 18:33:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339844</guid><dc:creator>Frederik Slijkerman</dc:creator><description>&lt;p&gt;And is there a reason not to use this?&lt;/p&gt;
&lt;p&gt;struct XYZ {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;...&lt;/p&gt;
&lt;p&gt;};&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339849</link><pubDate>Thu, 27 Mar 2008 18:37:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339849</guid><dc:creator>Skywing</dc:creator><description>&lt;p&gt;It is also required for the debugger. &amp;nbsp;The debugger requires the use of the UDT tag (e.g. struct tag) when fetching typeinformation, and not the typedef.&lt;/p&gt;
&lt;p&gt;(An unpredictable guid-like struct tag is generated for anonymous structs, as I recall. &amp;nbsp;You can't reference a type via a typedef, only the struct tag, using the .pdb codeview format.)&lt;/p&gt;
&lt;p&gt;- S&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339890</link><pubDate>Thu, 27 Mar 2008 18:56:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339890</guid><dc:creator>f0dder</dc:creator><description>&lt;p&gt;Slijkerman: C vs. C++. With the &amp;quot;typedef struct {...} MYTYPE;&amp;quot;, you can do &amp;quot;MYTYPE myvar;&amp;quot;. With &amp;quot;struct MYTYPE { ... };&amp;quot; you need &amp;quot;struct MYTYPE myvar;&amp;quot; in C.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339993</link><pubDate>Thu, 27 Mar 2008 19:43:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339993</guid><dc:creator>required</dc:creator><description>&lt;p&gt;&amp;gt; And is there a reason not to use this?&lt;/p&gt;
&lt;p&gt;Yeah, there is. Apparently the compiler somehow includes the header file three times if you do.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8339999</link><pubDate>Thu, 27 Mar 2008 19:50:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8339999</guid><dc:creator>required</dc:creator><description>&lt;P&gt;My question is: why does the midl compiler choose different names on different occasions? I mean, you know, computers are fairly predictable things which, when you tell them to do X, Y, and Z will do X, Y, and Z the same way each time. They're not Sirius Cybernetics Corporation elevators.&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;Look at some MIDL-generated files and it won't take long before you figure out the algorithm. Hint: 0001, 0002... -Raymond&lt;/I&gt;]&lt;/DIV&gt;</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340011</link><pubDate>Thu, 27 Mar 2008 19:59:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340011</guid><dc:creator>nksingh</dc:creator><description>&lt;p&gt;@required:&lt;/p&gt;
&lt;p&gt;How would the MIDL compiler choose the same name as last time? &amp;nbsp;The MIDL compiler probably chooses its current naming convention because no sane programmer would and therefore there's a lower risk of collision. &amp;nbsp;If for instance, MIDL chose MIDL_type or something like that, a programmer just might have already used that name and we'd be up a creek without a paddle.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340021</link><pubDate>Thu, 27 Mar 2008 20:06:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340021</guid><dc:creator>sandman</dc:creator><description>&lt;p&gt;I don't follow the point about it being a problem with the version control system - unless you are checking generated files into the VCS. &lt;/p&gt;
&lt;p&gt;Isn't that generally considered bad practice?&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340025</link><pubDate>Thu, 27 Mar 2008 20:10:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340025</guid><dc:creator>theorbtwo</dc:creator><description>&lt;p&gt;Ray's last point is also a good example of the rule &amp;quot;generated files shouldn't go in your version control system&amp;quot;.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340515</link><pubDate>Fri, 28 Mar 2008 01:28:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340515</guid><dc:creator>nksingh</dc:creator><description>&lt;p&gt;@sandman, theorbtwo&lt;/p&gt;
&lt;p&gt;Windows is pretty big and there are tons of generated files that change seldom/never (after all, if they change all the time, it's hard to maintain compatibility). &amp;nbsp;Hundreds of windows builds are produced every day from different groups, so it makes sense that if you're going to make a change to a generated file that's shared across parts of Windows (local generated files don't matter) that you should bear the costs of generating the file rather than imposing it on every build machine out there. &amp;nbsp;Some of those rules might work for normal projects which build relatively quickly, but can't work for Windows.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340824</link><pubDate>Fri, 28 Mar 2008 05:56:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340824</guid><dc:creator>Jess Sightler</dc:creator><description>&lt;p&gt;An even stronger rule than that one is &amp;quot;never say never&amp;quot;. &amp;nbsp;:-)&lt;/p&gt;
&lt;p&gt;I think that rule is more of a guideline for frequently generated files than something that someone should make as a hard, fast rule.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8340834</link><pubDate>Fri, 28 Mar 2008 06:11:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8340834</guid><dc:creator>Ian Johns</dc:creator><description>&lt;p&gt;Here's a related article on the subject that helped me recently realize how to properly use tag names to forward declare structures :&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.embedded.com/columns/programmingpointers/9900748"&gt;http://www.embedded.com/columns/programmingpointers/9900748&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8341406</link><pubDate>Fri, 28 Mar 2008 13:26:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8341406</guid><dc:creator>Michiel</dc:creator><description>&lt;p&gt;The reason to use forward declarations instead of including the header is not just to break cyclic dependencies. It also speeds up compilation. &lt;/p&gt;
&lt;p&gt;A compiler faced with a #include &amp;quot;X.h&amp;quot; may need to look in a dozen locations, and it can't really cache that information during a build (the &amp;quot;X.h&amp;quot; file may be the output of another build step)&lt;/p&gt;
&lt;p&gt;This isn't really new; see Lakos' Large Scale C++ Design.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8341714</link><pubDate>Fri, 28 Mar 2008 16:55:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8341714</guid><dc:creator>movl</dc:creator><description>&lt;p&gt;&amp;quot;Hundreds of windows builds are produced every day from different groups&amp;quot;&lt;/p&gt;
&lt;p&gt;Just wow! I take it Microsoft is really advanced these days in the field of quantum computing? Seriously, Mozilla for example is pretty slim in comparison but I can hardly build it overnight. To build NTOS+WOW+Shell+the rest in a day is incredible.&lt;/p&gt;
</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8341945</link><pubDate>Fri, 28 Mar 2008 18:45:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8341945</guid><dc:creator>required</dc:creator><description>&lt;P&gt;&amp;gt; it won't take long before you figure out the algorithm&lt;/P&gt;
&lt;P&gt;Well, my point was "why is the algorithm such that it may generate different names on susequent runs". Based on the example you gave ("typedef enum { ... } XYZ;") I don't see why it could not generate (for example):&lt;/P&gt;
&lt;P&gt;typedef enum __MIDL___MIDL_itf_XYZ&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;...&lt;/P&gt;
&lt;P&gt;} XYZ;&lt;/P&gt;
&lt;P&gt;since duplicate type declarations are invalid AFAIK (i.e. declaring two types in your original file called XYZ would be an error anyway).&lt;/P&gt;
&lt;P&gt;IMO, an algorithm seems to have been chose which will cause this problem, it isn't a problem inherent in generating names.&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;It gives different names because you changed the MIDL file between runs. Obviously if you change the input file, then it's not unreasonable that the output file changes too! -Raymond&lt;/I&gt;]&lt;/DIV&gt;</description></item><item><title>re: Why do structures get tag names even if there is a typedef?</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/03/27/8338530.aspx#8346953</link><pubDate>Tue, 01 Apr 2008 03:30:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8346953</guid><dc:creator>tim</dc:creator><description>&lt;P&gt;I've always wondered why the "tag" prefix is used. That is, why not just write it as:&lt;/P&gt;
&lt;P&gt;typedef struct XYZ {&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;} XYZ;&lt;/P&gt;
&lt;P&gt;instead of:&lt;/P&gt;
&lt;P&gt;typedef struct tagXYZ {&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;} XYZ;&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;I've always wondered whether people read the first sentence of the blog entry before posting a comment. -Raymond&lt;/I&gt;]&lt;/DIV&gt;</description></item></channel></rss>