Boost C++ Libraries: Ticket #1069: _InterlockedExchange, _InterlockedExchangeAdd have wrong signature https://svn.boost.org/trac10/ticket/1069 <p> Microsoft describes the signature of <code>_InterlockedExchange</code> as </p> <pre class="wiki">extern "C" LONG __cdecl _InterlockedExchange(LPLONG volatile Target, LONG Value); </pre><p> See <a class="ext-link" href="http://msdn2.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx"><span class="icon">​</span>http://msdn2.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx</a> </p> <p> In boost/detail/intrinsic.hpp, this function gets declared as </p> <pre class="wiki">extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long ); </pre><p> The problem is that <code>LPLONG volatile</code> is equivalent to <code>long * volatile</code>, not <code>long volatile *</code>. This results in compilation failures in the presence of a correct declaration of this function; i.e., the compiler complains that you cannot overload C functions. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1069 Trac 1.4.3 Braden McDaniel <braden@…> Thu, 28 Jun 2007 22:54:32 GMT attachment set https://svn.boost.org/trac10/ticket/1069 https://svn.boost.org/trac10/ticket/1069 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">interlocked.patch</span> </li> </ul> <p> Patch </p> Ticket Braden McDaniel <braden@…> Thu, 28 Jun 2007 22:56:20 GMT <link>https://svn.boost.org/trac10/ticket/1069#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1069#comment:1</guid> <description> <p> As suggested in the summary, the declaration of _InterlockedExchangeAdd has the same problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Tue, 10 Jul 2007 00:00:47 GMT</pubDate> <title>status, component, severity changed; owner set https://svn.boost.org/trac10/ticket/1069#comment:2 https://svn.boost.org/trac10/ticket/1069#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Peter Dimov</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">smart_ptr</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> On which compiler are you seeing this behavior? The actual declaration in &lt;windows.h&gt; is as follows: </p> <p> WINBASEAPI LONG WINAPI <a class="missing wiki">InterlockedExchange</a>( </p> <blockquote> <p> IN OUT LONG volatile *Target, IN LONG Value ); </p> </blockquote> <p> with the volatile correctly applied to *Target. </p> Ticket braden@… Tue, 10 Jul 2007 01:47:26 GMT <link>https://svn.boost.org/trac10/ticket/1069#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1069#comment:3</guid> <description> <p> The compiler is Visual C++ 7.1. The problem arises because code in another dependency has declared the function the way the Microsoft documentation recommends. Since the signatures are different, the compiler complains that an <code>extern "C"</code> function has been overloaded. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sun, 15 Jul 2007 16:06:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1069#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1069#comment:4</guid> <description> <p> The Microsoft documentation is wrong in this case. If we change the code to be wrong as well, the signatures will no longer match the ones in &lt;windows.h&gt;. The documentation for InterlockedExchange </p> <p> <a class="ext-link" href="http://msdn2.microsoft.com/en-us/library/ms683590.aspx"><span class="icon">​</span>http://msdn2.microsoft.com/en-us/library/ms683590.aspx</a> </p> <p> correctly specifies the signature as taking LONG volatile*. BTW, you can't declare a function parameter as long * volatile, the volatile is ignored. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sat, 21 Jul 2007 16:43:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1069#comment:5 https://svn.boost.org/trac10/ticket/1069#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket