Boost C++ Libraries: Ticket #8817: Boost Thread Windows CE _createthreadex handling breaks mingw w64 https://svn.boost.org/trac10/ticket/8817 <p> The applicable code: </p> <pre class="wiki">#ifndef BOOST_HAS_THREADEX // Windows CE doesn't define _beginthreadex typedef void* uintptr_t; // ... more code #endif </pre><p> For some reason mingw-w64 will evaluate this code. This redefines uintptr_t (as well as _beginthreadex related code), which causes the build to fail. </p> <p> <a class="ext-link" href="https://groups.google.com/d/msg/microsoft.public.windowsce.app.development/o_7hgu0G-II/VhuEmWk1ROIJ"><span class="icon">​</span>This post</a> has a solution which avoids defining uintptr_t at all, and is targeted specifically for Windows CE rather than some arbitrary BOOST_HAS_THREADEX macro define. </p> <p> I've created a patch which incorporates the fix and it does compile with mingw-w64 (mingw-builds, gcc 4.8.1 targeting windows x64), and doesn't break building with VS2012 (really shouldn't break any VS builds targeting Win32). </p> <p> I don't know when the problem first occurs, but I do know that it fails in 1.53.0 all the way to trunk (my current working directory is <a class="changeset" href="https://svn.boost.org/trac10/changeset/85020" title="Refactored aligned memory allocation. Added support for Android. Fixes ...">r85020</a>). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8817 Trac 1.4.3 Andrew Ho <helloworld922@…> Sat, 13 Jul 2013 10:38:10 GMT attachment set https://svn.boost.org/trac10/ticket/8817 https://svn.boost.org/trac10/ticket/8817 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread.cpp.patch</span> </li> </ul> <p> patch for libs\thread\src\win32\thread.cpp </p> Ticket Andrew Ho <helloworld922@…> Sat, 13 Jul 2013 18:51:42 GMT attachment set https://svn.boost.org/trac10/ticket/8817 https://svn.boost.org/trac10/ticket/8817 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">wince.patch</span> </li> </ul> <p> patch which fixes boost threads and also moves wince configs to win32.hpp </p> Ticket Andrew Ho <helloworld922@…> Sat, 13 Jul 2013 18:53:34 GMT <link>https://svn.boost.org/trac10/ticket/8817#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:1</guid> <description> <p> After digging through the Boost configs, it seems that these defines are part of visualc.hpp: </p> <pre class="wiki">#if defined(_WIN32_WCE) || defined(UNDER_CE) // Windows CE does not have a conforming signature for swprintf # define BOOST_NO_SWPRINTF #endif // we have ThreadEx or GetSystemTimeAsFileTime unless we're running WindowsCE #if !defined(_WIN32_WCE) &amp;&amp; !defined(UNDER_CE) # define BOOST_HAS_THREADEX # define BOOST_HAS_GETSYSTEMTIMEASFILETIME #endif </pre><p> This probably should be included in win32.hpp, or perhaps in a new platform config file wince.hpp. </p> <p> Perhaps this is a better option? I still think the changed no _beginthreadex may work betterh, though, as we probably shouldn't be typdef'ing uintptr_t anyways. </p> <p> Added an updated patch which fixes both win32/thread.hpp as well as the threadex wince platform config. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 03 Aug 2013 05:25:54 GMT</pubDate> <title>owner, component changed https://svn.boost.org/trac10/ticket/8817#comment:2 https://svn.boost.org/trac10/ticket/8817#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">config</span> </li> </ul> <p> I think this should be fixed in Boost.Config. </p> Ticket Andrew Ho <helloworld922@…> Sat, 03 Aug 2013 07:28:35 GMT <link>https://svn.boost.org/trac10/ticket/8817#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:3</guid> <description> <p> The problem is in Boost.Config and Boost.Thread. </p> <p> Obviously the work-arounds for Windows CE should not be used when compiling with MinGW (unless targeting Windows CE specifically), so Boost.Config must be changed. </p> <p> IMO Boost.Thread should also be changed because defining uintptr_t really shouldn't be done at all. I would imagine any modern compiler targeting Windows CE might have uintptr_t defined (it is standard C++ after all), in which case the compile will fail again. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Wed, 14 Aug 2013 12:26:12 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/8817#comment:4 https://svn.boost.org/trac10/ticket/8817#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">jim@…</span> added </li> </ul> Ticket Jim Bell <jim@…> Thu, 15 Aug 2013 11:21:34 GMT attachment set https://svn.boost.org/trac10/ticket/8817 https://svn.boost.org/trac10/ticket/8817 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">minimal-thread.cpp.patch</span> </li> </ul> <p> Minimal patch to libs/thread/src/win32/thread.cpp: include &lt;boost/cstdint.hpp&gt; and yank the uintptr_t typedef. </p> Ticket Jim Bell <jim@…> Thu, 15 Aug 2013 11:32:35 GMT owner, component changed; keywords set https://svn.boost.org/trac10/ticket/8817#comment:5 https://svn.boost.org/trac10/ticket/8817#comment:5 <ul> <li><strong>keywords</strong> MinGW uintptr_t added </li> <li><strong>owner</strong> changed from <span class="trac-author">John Maddock</span> to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">config</span> → <span class="trac-field-new">thread</span> </li> </ul> <p> Added a minimal patch to libs/thread/src/win32/thread.cpp which I verified to work with MinGW gcc 4.8, and both boost trunk and release SVN branches. Using &lt;boost/cstdint.hpp&gt; for the typedef for uintptr_t maximizes confidence that it will work for WinCE as well. (And should WinCE fail, pushes the fix from thread to config where it belongs.) With this change being only to thread.cpp, I'm changing the component from config back to thread. </p> Ticket Andrew Ho <helloworld922@…> Thu, 15 Aug 2013 17:21:54 GMT attachment set https://svn.boost.org/trac10/ticket/8817 https://svn.boost.org/trac10/ticket/8817 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">mingw.config.patch</span> </li> </ul> <p> patch only for config detection with MinGW and WinCE </p> Ticket Andrew Ho <helloworld922@…> Thu, 15 Aug 2013 17:28:20 GMT <link>https://svn.boost.org/trac10/ticket/8817#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:6</guid> <description> <p> Should the code for detecting BOOST_NO_SWPRINTF, BOOST_HAS_THREADEX, and BOOST_HAS_GETSYSTEMTIMEASFILETIME be moved to win32.hpp (from visualc.hpp)? These are platform-specific defines, not compiler-specific. </p> <p> You should be able to verify this with Mingw testing this code: </p> <pre class="wiki">#include &lt;boost/config&gt; #include &lt;iostream&gt; int main(void) { #ifndef BOOST_HAS_THREADEX // This should be true for any compiler targeting Windows and can use the WinAPI, which MinGW can std::cout &lt;&lt; "didn't detect BOOST_HAS_THREADEX" &lt;&lt; std::endl; #else std::cout &lt;&lt; "has BOOST_HAS_THREADEX" &lt;&lt; std::endl; #endif } </pre><p> As-is, MinGW will still not detect these correctly because it doesn't (and shouldn't) include visualc.hpp. However, when targeting Windows it should and will include win32.hpp and detection will work as intended. </p> <p> I've added a smaller patch which only applies these fixes to Config, so applying <strong>minimal-thread.cpp.patch</strong> and <strong>mingw.config.patch</strong> should fully fix Boost.Config and Boost.Thread. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Thu, 15 Aug 2013 17:37:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8817#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:7</guid> <description> <p> Andrew: I have to say I didn't look too closely at your proposed solution, but was working backwards from (a lot of) failed regression tests and found this ticket. I'd say (1) you might want to split this into a separate ticket for config, and (2) present it as a specific failed regression test, or a missing regression test. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Tue, 27 Aug 2013 22:45:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8817#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:8</guid> <description> <p> I'm pretty sure was caused by <a class="changeset" href="https://svn.boost.org/trac10/changeset/82777" title="Thread: manage #7980">[82777]</a> on thread.cpp, which changed the &lt;thread.hpp&gt; include to &lt;thread_only.hpp&gt;. Looking for a way to change this ticket's owner, but apparently don't have permission. Will look for him on lists (viboes) and contact directly. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 31 Aug 2013 10:16:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8817#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8817#comment:5" title="Comment 5">Jim Bell &lt;jim@…&gt;</a>: </p> <blockquote class="citation"> <p> Added a minimal patch to libs/thread/src/win32/thread.cpp which I verified to work with MinGW gcc 4.8, and both boost trunk and release SVN branches. Using &lt;boost/cstdint.hpp&gt; for the typedef for uintptr_t maximizes confidence that it will work for WinCE as well. (And should WinCE fail, pushes the fix from thread to config where it belongs.) With this change being only to thread.cpp, I'm changing the component from config back to thread. </p> </blockquote> <p> This code was working well on mingw 32. What has been changed in mingw 64? Have you tested your patch on mingw 32? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 01 Sep 2013 07:26:48 GMT</pubDate> <title>owner, status, version, milestone changed https://svn.boost.org/trac10/ticket/8817#comment:10 https://svn.boost.org/trac10/ticket/8817#comment:10 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost Development Trunk</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85540" title="Thread: try to handle with not needed definition of uintptr_t #8817.">[85540]</a>. </p> Ticket Jim Bell <jim@…> Sun, 01 Sep 2013 21:43:46 GMT <link>https://svn.boost.org/trac10/ticket/8817#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:11</guid> <description> <p> I'm reverting the trunk patch on my MinGW-gcc testers and will begin to re-cycle those tests. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Mon, 09 Sep 2013 10:22:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8817#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:12</guid> <description> <p> It appears that all trunk tests have run with revisions above <a class="changeset" href="https://svn.boost.org/trac10/changeset/85540" title="Thread: try to handle with not needed definition of uintptr_t #8817.">[85540]</a>, and without issue. I think this can go to the release branch and close the ticket. </p> </description> <category>Ticket</category> </item> <item> <author>Andrew Ho <helloworld922@…></author> <pubDate>Mon, 09 Sep 2013 16:21:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8817#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8817#comment:13</guid> <description> <p> I submitted the other portion of this issue with Boost.Config as <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9095" title="#9095: Bugs: Boost Mingw w64 config isn't detecting correctly (closed: fixed)">#9095</a>. This should allow proper detection of Windows platform features on compilers other than VS by Boost.Config. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 09 Sep 2013 17:02:08 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8817#comment:14 https://svn.boost.org/trac10/ticket/8817#comment:14 <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">fixed</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85621" title="Thread: fix #8417.">[85621]</a>. </p> Ticket