<?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>The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx</link><description>To export unmangled, you need a DEF file.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10311979</link><pubDate>Wed, 30 May 2012 19:48:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10311979</guid><dc:creator>Dave Bacher</dc:creator><description>&lt;p&gt;@Joshua:&lt;/p&gt;
&lt;p&gt;If you pop over to msdn.microsoft.com, and search on &amp;quot;Module Definition File,&amp;quot; you&amp;#39;ll find the format specs.&lt;/p&gt;
&lt;p&gt;However, basically, you do this:&lt;/p&gt;
&lt;p&gt;x=__x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @1&lt;/p&gt;
&lt;p&gt;x2=_x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @2&lt;/p&gt;
&lt;p&gt;x3=x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@3&lt;/p&gt;
&lt;p&gt;If you screw it up, the linker gives the usual suite of complaints -- General Protection Fault, Ambiguous Symbol, symbol not found, etc.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10311979" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10311335</link><pubDate>Tue, 29 May 2012 14:53:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10311335</guid><dc:creator>David Walker</dc:creator><description>&lt;p&gt;Yes, I definitely understand the incorrect interpretation of the documentation. &amp;nbsp;It&amp;#39;s hard to write good documentation!&lt;/p&gt;
&lt;p&gt;When I see something that says &amp;quot;if such and such is not desired, do this&amp;quot;, I naturally assume that if I &amp;quot;do this&amp;quot;, then &amp;quot;such and such&amp;quot; won&amp;#39;t happen. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10311335" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310770</link><pubDate>Sun, 27 May 2012 10:27:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310770</guid><dc:creator>foo</dc:creator><description>&lt;p&gt;@Yuriy: Ah right, so using extern &amp;quot;C&amp;quot; disabled C++ name mangling. Cool.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310770" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310724</link><pubDate>Sat, 26 May 2012 19:58:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310724</guid><dc:creator>Medinoc</dc:creator><description>&lt;p&gt;I remember I failed a school project because I assumed prefixing C symbols with an underscore was universal after seeing on both DOS (QuickC) and Windows (Visual and MinGW). I learned at my expense that *n*x systems don&amp;#39;t add anything.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310724" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310697</link><pubDate>Sat, 26 May 2012 13:45:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310697</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;I must say I initially also read the documentation as ‘extern &amp;quot;C&amp;quot; will disable name mangling’. Of course, when I tried to use the DLL I quickly discovered that this was not case. But I&amp;#39;m afraid it was easier to add ‘-Wl,--kill-at’ to the makefile than to have the added burden of a .def-file that must be kept in synch with the source files.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310697" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310688</link><pubDate>Sat, 26 May 2012 12:54:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310688</guid><dc:creator>Yuriy Gettya</dc:creator><description>&lt;p&gt;@foo:&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve got a .dll compiled with /Gd (__cdecl), here&amp;#39;s how a function is prototyped and declared:&lt;/p&gt;
&lt;p&gt;extern &amp;quot;C&amp;quot; xENGINE_API HRESULT CreateInstance(shared_ptr&amp;lt;xFramework::IPlugin&amp;gt;&amp;amp; ppPlugin);&lt;/p&gt;
&lt;p&gt;HRESULT CreateInstance(shared_ptr&amp;lt;xFramework::IPlugin&amp;gt;&amp;amp; ppPlugin)&lt;/p&gt;
&lt;p&gt;----- results of dumpbin:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;ordinal hint RVA &amp;nbsp; &amp;nbsp; &amp;nbsp;name&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;0 00011398 CreateInstance = @ILT+915(_CreateInstance)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310688" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310653</link><pubDate>Sat, 26 May 2012 06:00:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310653</guid><dc:creator>foo</dc:creator><description>&lt;p&gt;@Yuriy. Maybe I&amp;#39;m missing something, but I don&amp;#39;t see that using MSVC if I declare &amp;amp; define foo() as you suggest, except with __stdcall convention.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310653" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310611</link><pubDate>Fri, 25 May 2012 22:51:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310611</guid><dc:creator>Joshua</dc:creator><description>&lt;p&gt;How does the linker figure it out at build time that the compiler exported symbol x@42 is the .def symbol x.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure this can happen but if it did I&amp;#39;d imagine it would be worse:&lt;/p&gt;
&lt;p&gt;_x&lt;/p&gt;
&lt;p&gt;__x&lt;/p&gt;
&lt;p&gt;EXPORTS x&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310611" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310521</link><pubDate>Fri, 25 May 2012 17:41:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310521</guid><dc:creator>640k</dc:creator><description>&lt;p&gt;Why is this even an issue 2012? The docs should have been super clear on this for the last 20 years.&lt;/p&gt;
&lt;div class="post"&gt;[&lt;i&gt;We thought the docs were clear on this, especially since nobody asked about it until 2011. -Raymond&lt;/i&gt;]&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310521" width="1" height="1"&gt;</description></item><item><title>re: The extern "C" specifier disables C++ mangling, but that doesn't mean it disables mangling</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2012/05/25/10310148.aspx#10310520</link><pubDate>Fri, 25 May 2012 17:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10310520</guid><dc:creator>Steve Friedl</dc:creator><description>&lt;p&gt;@Aaron - the C language itself doesn&amp;#39;t provide for this, but an implementation might. Microsoft C compilers disambiguate the calling convention to avoid catastrophic stack corruption on mismatch.&lt;/p&gt;
&lt;p&gt;Ref: &lt;a rel="nofollow" target="_new" href="http://unixwiz.net/techtips/win32-callconv.html"&gt;unixwiz.net/.../win32-callconv.html&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10310520" width="1" height="1"&gt;</description></item></channel></rss>