Boost C++ Libraries: Ticket #3901: ASIO and macro min and max on Windows https://svn.boost.org/trac10/ticket/3901 <p> Dears, </p> <p> There is little problem with ASIO on windows. ASIO is using windows.h header. That header defines "min" and "max" macros. </p> <p> So immediately asio is conflicting with standard &lt;limits&gt; and &lt;algorithm&gt; headers. </p> <p> The error generated by the compilers is higlhy not readable. Also regular user of the asio does not know that windows.h is included and pollute standard C++ code with mentioned macros. </p> <p> Try to use ::std::numeric_limits&lt;int&gt;::min() ::std::numeric_limits&lt;int&gt;::max() as well as ::std::min() together with ASIO. </p> <p> For users would be perfect if you could simply put #undef min and #undef max just after inclusion of any windows.h file. </p> <p> The problem is more complicated because the same code is working on Linux, so from C++ portable code it is uncomfortable to have such a intrusions. </p> <p> Best regards, Seweryn Habdank-Wojewodzki </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3901 Trac 1.4.3 jan.boehme@… Sat, 13 Feb 2010 18:16:41 GMT <link>https://svn.boost.org/trac10/ticket/3901#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3901#comment:1</guid> <description> <p> This is an issue asio shouldn't care about. Just &lt;define&gt;NOMINMAX when building on this platform. </p> </description> <category>Ticket</category> </item> <item> <author>habdank@…</author> <pubDate>Mon, 15 Feb 2010 12:47:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3901#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3901#comment:2</guid> <description> <p> Hi, </p> <p> To be honest I disagree that it is not a matter of ASIO. </p> <p> This is a matter of good encapsulation. Inclusion of the windows.h is a private matter of ASIO. Even more if ASIO would use PIMPL idiom maybe no one would be affected by that macros. </p> <p> Also consider that if ASIO will stop using windows.h for some reasons, any code will be still affected - then by having useless undefs or NOMINMAX build flag. </p> <p> As I told that macros are conflicting with standard C++. </p> <p> Off course I could build my software with NOMINMAX flag or do the #undef on my own :-). </p> <p> Best regards, Seweryn Habdank-Wojewodzki. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Thu, 18 Mar 2010 01:33:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3901#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3901#comment:3</guid> <description> <p> Fixed on trunk in changeset <a class="changeset" href="https://svn.boost.org/trac10/changeset/60681" title="Define NOMINMAX for all Windows compilers, not just Cygwin. Users can ...">[60681]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 18 Mar 2010 16:08:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3901#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3901#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3901#comment:3" title="Comment 3">chris_kohlhoff</a>: </p> <blockquote class="citation"> <p> Fixed on trunk in changeset <a class="changeset" href="https://svn.boost.org/trac10/changeset/60681" title="Define NOMINMAX for all Windows compilers, not just Cygwin. Users can ...">[60681]</a>. </p> </blockquote> <p> Thanks! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sun, 21 Mar 2010 09:39:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3901#comment:5 https://svn.boost.org/trac10/ticket/3901#comment:5 <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/60741" title="Merge from trunk. ........ r60681 | chris_kohlhoff | 2010-03-18 ...">[60741]</a>) Merge from trunk. </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60681" title="Define NOMINMAX for all Windows compilers, not just Cygwin. Users can ...">r60681</a> | chris_kohlhoff | 2010-03-18 12:32:34 +1100 (Thu, 18 Mar 2010) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Define NOMINMAX for all Windows compilers, not just Cygwin. Users can define BOOST_ASIO_NO_NOMINMAX to suppress this definition. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3901" title="#3901: Bugs: ASIO and macro min and max on Windows (closed: fixed)">#3901</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60687" title="Use a bitmask type for the resolver flags, as per the TR2 proposal. ...">r60687</a> | chris_kohlhoff | 2010-03-18 17:23:38 +1100 (Thu, 18 Mar 2010) | 4 lines </p> </blockquote> <p> </p> <blockquote> <p> Use a bitmask type for the resolver flags, as per the TR2 proposal. This will prevent implicit conversion from int to flags, allowing the compiler to catch cases where users incorrectly pass a numeric port number as the service name. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60689" title="Fix bug where 0-byte reads were incorrectly passing an eof error_code ...">r60689</a> | chris_kohlhoff | 2010-03-18 22:08:19 +1100 (Thu, 18 Mar 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix bug where 0-byte reads were incorrectly passing an eof error_code to the handler. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4023" title="#4023: Bugs: Read handler has EOF error_code (closed: fixed)">#4023</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60705" title="Fix epoll_reactor bug where cancelled operations would complete with a ...">r60705</a> | chris_kohlhoff | 2010-03-20 00:08:04 +1100 (Sat, 20 Mar 2010) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix epoll_reactor bug where cancelled operations would complete with a "success" error_code. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60717" title="More extensive read and write tests. ">r60717</a> | chris_kohlhoff | 2010-03-20 10:23:28 +1100 (Sat, 20 Mar 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> More extensive read and write tests. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60722" title="WinCE doesn't provide InitializeCriticalSectionAndSpinCount. ">r60722</a> | chris_kohlhoff | 2010-03-20 10:57:50 +1100 (Sat, 20 Mar 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> WinCE doesn't provide <a class="missing wiki">InitializeCriticalSectionAndSpinCount</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60723" title="Fix cancellation. ">r60723</a> | chris_kohlhoff | 2010-03-20 10:58:48 +1100 (Sat, 20 Mar 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix cancellation. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/60725" title="Use cancel() to avoid Windows behaviour where a connection is reset if ...">r60725</a> | chris_kohlhoff | 2010-03-20 10:59:48 +1100 (Sat, 20 Mar 2010) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Use cancel() to avoid Windows behaviour where a connection is reset if the socket is closed while there is a pending read operation. </p> </blockquote> <p> ........ </p> Ticket