Boost C++ Libraries: Ticket #7373: Boost ASIO has a wrong swprintf interface definition for MinGW https://svn.boost.org/trac10/ticket/7373 <p> In the file <a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/boost/asio/detail/impl/win_static_mutex.ipp"><span class="icon">​</span>win_static_mutex.ipp</a> on the lines 45-51 one can read: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#if BOOST_WORKAROUND(BOOST_MSVC, &gt;= 1400) &amp;&amp; !defined(UNDER_CE)</span> <span class="n">swprintf_s</span><span class="p">(</span><span class="n">mutex_name</span><span class="p">,</span> <span class="mi">128</span><span class="p">,</span> <span class="cp">#else </span><span class="c1">// BOOST_WORKAROUND(BOOST_MSVC, &gt;= 1400) &amp;&amp; !defined(UNDER_CE)</span> <span class="n">swprintf</span><span class="p">(</span><span class="n">mutex_name</span><span class="p">,</span> <span class="cp">#endif </span><span class="c1">// BOOST_WORKAROUND(BOOST_MSVC, &gt;= 1400) &amp;&amp; !defined(UNDER_CE)</span> <span class="sa">L</span><span class="s">&quot;asio-58CCDC44-6264-4842-90C2-F3C545CB8AA7-%u-%p&quot;</span><span class="p">,</span> <span class="k">static_cast</span><span class="o">&lt;</span><span class="kt">unsigned</span> <span class="kt">int</span><span class="o">&gt;</span><span class="p">(</span><span class="o">::</span><span class="n">GetCurrentProcessId</span><span class="p">()),</span> <span class="k">this</span><span class="p">);</span> </pre></div></div><p> As one can see there are two different signatures. The first one is for Visual Studio's swprintf_s function and the second one should be for the rest, but this function is declared differently in MinGW and also takes an integer as second argument. The correct interface is declared in MinGW's libintl.h header on line 419 as following: </p> <div class="wiki-code"><div class="code"><pre><span class="k">extern</span> <span class="kt">int</span> <span class="nf">swprintf</span> <span class="p">(</span><span class="kt">wchar_t</span> <span class="o">*</span><span class="p">,</span> <span class="kt">size_t</span><span class="p">,</span> <span class="k">const</span> <span class="kt">wchar_t</span> <span class="o">*</span><span class="p">,</span> <span class="p">...);</span> </pre></div></div><p> That deceleration is also what the C99 standard declares: <a class="ext-link" href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf"><span class="icon">​</span>§7.24.2.3 (p. 362)</a> </p> <p> A fix would either involve to change the #else statement completely to add a second parameter as with swprintf_s or another check for MinGW. Probably the better solution would be to completely eliminate the swprintf function and make use of streams. </p> <p> If tested the version 1.49, 1.50 and 1.51 and for all, my application fails to build, simply by including the ASIO header. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7373 Trac 1.4.3 viboes Tue, 18 Sep 2012 16:57:02 GMT component changed; owner set https://svn.boost.org/trac10/ticket/7373#comment:1 https://svn.boost.org/trac10/ticket/7373#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">asio</span> </li> </ul> Ticket chris_kohlhoff Sun, 30 Dec 2012 23:17:22 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7373#comment:2 https://svn.boost.org/trac10/ticket/7373#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/82290" title="Merge from trunk: * Fix some 64-to-32-bit conversion warnings. Fixes ...">[82290]</a>) Merge from trunk: </p> <ul><li>Fix some 64-to-32-bit conversion warnings. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7459" title="#7459: Bugs: warnings in boost::asio (closed: fixed)">#7459</a> </li></ul><ul><li>Fix typos in comments. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7761" title="#7761: Bugs: Minor comment typo in boost/asio/ssl/detail/stream_core.hpp (closed: fixed)">#7761</a> </li></ul><ul><li>Fix error in example embedded in basic_socket::get_option's documentation. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7562" title="#7562: Bugs: Old documentation for reading socket options (closed: fixed)">#7562</a> </li></ul><ul><li>Use long rather than int for SSL_CTX options, to match OpenSSL. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7209" title="#7209: Bugs: Asio SSL overflow in constant (closed: fixed)">#7209</a> </li></ul><ul><li>Use _snwprintf to address a compile error due to the changed swprintf signature in recent versions of MinGW. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7373" title="#7373: Bugs: Boost ASIO has a wrong swprintf interface definition for MinGW (closed: fixed)">#7373</a> </li></ul><ul><li>Fix deadlock that can occur on Windows when shutting down a pool of io_service threads due to running out of work. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7552" title="#7552: Bugs: win_iocp_io_service hangs due to a race condition (closed: fixed)">#7552</a> </li></ul><ul><li>Enable noexcept qualifier for error categories. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7797" title="#7797: Feature Requests: Add noexcept to conform with C++11 after #7278 (closed: fixed)">#7797</a> </li></ul><ul><li>Treat errors from accept as non-fatal. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7488" title="#7488: Bugs: Accept Errors (closed: fixed)">#7488</a> </li></ul><ul><li>Add a small block recycling optimisation. </li></ul><ul><li>Version bump. </li></ul><ul><li>Regenerate documentation. </li></ul> Ticket