Boost C++ Libraries: Ticket #1740: date_time includes <windows.h> https://svn.boost.org/trac10/ticket/1740 <p> The header &lt;boost/date_time/filetime_functions.hpp&gt; includes &lt;windows.h&gt; by default, and there is no way to turn this off (e.g. BOOST_USE_WINDOWS_H). This is a problem as this brings in the min,max,ERROR,etc. macros in. (This header is included if you include &lt;boost/date_time.hpp&gt; </p> <p> As date_time has to be compiled anyway, it would be very nice to have this functionality in the library somewhere and not include &lt;windows.h&gt;. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1740 Trac 1.4.3 anonymous Thu, 10 Apr 2008 19:03:57 GMT <link>https://svn.boost.org/trac10/ticket/1740#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1740#comment:1</guid> <description> <p> This is also breaking Asio, as Asio wants to include winsock, see: <a class="ext-link" href="http://permalink.gmane.org/gmane.comp.lib.boost.devel/172990"><span class="icon">​</span>http://permalink.gmane.org/gmane.comp.lib.boost.devel/172990</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anteru</dc:creator> <pubDate>Thu, 10 Apr 2008 19:05:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1740#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1740#comment:2</guid> <description> <p> Forgot to set the name -- this comment is from me, Anteru </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 08 Jul 2008 15:09:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1740#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1740#comment:3</guid> <description> <p> This is a very serious bug for us as well as it completely breaks our entire project. It does not appear that any code which uses Windows.h is required to be inline or even public. We have yet to find a work around which allows us to build using 1.35 and have been stuck on 1.34.1. </p> <p> A fix soon would be greatly appreciated. </p> </description> <category>Ticket</category> </item> <item> <author>emilm@…</author> <pubDate>Sat, 11 Oct 2008 08:29:26 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/1740 https://svn.boost.org/trac10/ticket/1740 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">date_time.patch</span> </li> </ul> Ticket emilm@… Sat, 11 Oct 2008 08:29:43 GMT <link>https://svn.boost.org/trac10/ticket/1740#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1740#comment:4</guid> <description> <p> Please find attached a patch to solve this issue and the test report of the library on the compiler I have at my disposal. I have taken precautions in order to ensure it will work on x64 Windows (please see comments related to the conversion between FILETIME and <span class="underline">int64) and I see no reason it should have changed for other platforms, but only testing will tell. </span></p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Thu, 13 Nov 2008 18:11:37 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1740#comment:5 https://svn.boost.org/trac10/ticket/1740#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> Ticket anonymous Mon, 17 Aug 2009 15:15:50 GMT status, version changed; keywords set; resolution deleted https://svn.boost.org/trac10/ticket/1740#comment:6 https://svn.boost.org/trac10/ticket/1740#comment:6 <ul> <li><strong>keywords</strong> windows.h date_time added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.35.0</span> → <span class="trac-field-new">Boost 1.39.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> If you do include windows.h anywhere in boost, you need the following two lines of code just above it: </p> <pre class="wiki">#undef WIN32_LEAN_AND_MEAN // add this... #define WIN32_LEAN_AND_MEAN // ...and this #include &lt;windows.h&gt; </pre><p> Otherwise, if some other 3rd party lib includes &lt;windows.h&gt;, it will break the build unless the header files are in a very specific order, which is extremely tedious to maintain. </p> Ticket anonymous Fri, 25 Sep 2009 20:09:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1740#comment:7 https://svn.boost.org/trac10/ticket/1740#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1740#comment:6" title="Comment 6">anonymous</a>: </p> <blockquote class="citation"> <p> If you do include windows.h anywhere in boost, you need the following two lines of code just above it: </p> <pre class="wiki">#undef WIN32_LEAN_AND_MEAN // add this... #define WIN32_LEAN_AND_MEAN // ...and this #include &lt;windows.h&gt; </pre><p> Otherwise, if some other 3rd party lib includes &lt;windows.h&gt;, it will break the build unless the header files are in a very specific order, which is extremely tedious to maintain. </p> </blockquote> <p> First, Boost.<a class="missing wiki">DateTime</a> no longer includes windows.h by default. You can explicitly enable it to include windows.h by defining BOOST_USE_WINDOWS_H. </p> <p> Second, defining WIN32_LEAN_AND_MEAN will disable quite a few components in windows.h. Boost.<a class="missing wiki">DateTime</a> is in no position to enforce this decision in its headers. If you want windows.h to behave like when WIN32_LEAN_AND_MEAN is defined, you should define it in your project, before including any headers. </p> Ticket