Boost C++ Libraries: Ticket #9124: Boost.Thread using of _beginthreadex prohibits its use on Windows Store application https://svn.boost.org/trac10/ticket/9124 <p> _beginthreadex function is absent in Windows Store application so one can't link with boost.thread when build an application which targets windows 8.1. It seems that it did link well with apps targeting Windows 8.0, though. </p> <p> See the full list of the forsaken API here: <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9124 Trac 1.4.3 viboes Tue, 17 Sep 2013 20:17:22 GMT <link>https://svn.boost.org/trac10/ticket/9124#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:1</guid> <description> <p> I'm unable to test on this platform. Do you have a patch? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 17 Sep 2013 20:19:51 GMT</pubDate> <title>owner, status, description changed https://svn.boost.org/trac10/ticket/9124#comment:2 https://svn.boost.org/trac10/ticket/9124#comment:2 <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>description</strong> modified (<a href="/trac10/ticket/9124?action=diff&amp;version=2">diff</a>) </li> </ul> Ticket viboes Tue, 17 Sep 2013 20:20:22 GMT summary changed https://svn.boost.org/trac10/ticket/9124#comment:3 https://svn.boost.org/trac10/ticket/9124#comment:3 <ul> <li><strong>summary</strong> <span class="trac-field-old">Boost.Thread using of _beginthreadx prohibits its use on Windows Store application</span> → <span class="trac-field-new">Boost.Thread using of _beginthreadex prohibits its use on Windows Store application</span> </li> </ul> Ticket viboes Tue, 17 Sep 2013 20:25:05 GMT <link>https://svn.boost.org/trac10/ticket/9124#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:4</guid> <description> <p> Boost.Config contain in boost/config/compiler/visualc.hpp the definition of </p> <pre class="wiki">// 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> Do you have a define that can be used to don't define BOOST_HAS_THREADEX </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Wed, 18 Sep 2013 11:03:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:5</guid> <description> <p> Yes it has this define but _WIN32_WCE and UNDER_CE bring some more than just implementation of _beginthreadex. It adds some more includes etc. It would be better to have different define for WinRT. I've just tried with _WIN32_WCE and it broke Interlocked* family. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 19 Sep 2013 17:59:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9124#comment:5" title="Comment 5">ixSci &lt;beholder@…&gt;</a>: </p> <blockquote class="citation"> <p> Yes it has this define but _WIN32_WCE and UNDER_CE bring some more than just implementation of _beginthreadex. It adds some more includes etc. It would be better to have different define for WinRT. I've just tried with _WIN32_WCE and it broke Interlocked* family. </p> </blockquote> <p> What a meant was a define that is specific to your platform that can be used to inhibit the definition of BOOST_HAS_THREADEX as for example </p> <p> #if !defined(_WIN32_WCE) &amp;&amp; !defined(UNDER_CE) &amp;&amp; !defined(XXX) # define BOOST_HAS_THREADEX # define BOOST_HAS_GETSYSTEMTIMEASFILETIME #endif </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Fri, 20 Sep 2013 04:15:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:7</guid> <description> <p> I belive there is no such a define out there. Windows 8.1 is not just Metro apps but plain old apps also. So it is up to the user to build boost specifically for Metro apps. So I propose to either add new define(e.g UNDER_WINRT) which allows to not define BOOST_HAS_THREADEX or(better) replace existing BOOST_HAS_THREADEX with something like BOOST_IMPL_THREADEX. If BOOST_IMPL_THREADEX defined then use boost implemented _beginthreadex if not then use the native one. It allows to build boost.thread with custom _beginthreadex just by defining macros in bjam. Also it won't disturb current code much since only a few places must be touch to replace current logic about BOOST_HAS_THREADEX </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 20 Sep 2013 06:17:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9124#comment:7" title="Comment 7">ixSci &lt;beholder@…&gt;</a>: </p> <blockquote class="citation"> <p> I belive there is no such a define out there. Windows 8.1 is not just Metro apps but plain old apps also. So it is up to the user to build boost specifically for Metro apps. So I propose to either add new define(e.g UNDER_WINRT) which allows to not define BOOST_HAS_THREADEX </p> </blockquote> <p> This can be done, see bellow. The major drawback is that you this forces you to have your own Boost installation. Are you sure there is no such a macro or set of macros (versions) that tell that _beginthreadex is not defined? </p> <p> or(better) replace existing BOOST_HAS_THREADEX with something like BOOST_IMPL_THREADEX. If BOOST_IMPL_THREADEX defined then use boost implemented _beginthreadex if not then use the native one. It allows to build boost.thread with custom _beginthreadex just by defining macros in bjam. </p> <blockquote class="citation"> <p> Also it won't disturb current code much since only a few places must be touch to replace current logic about BOOST_HAS_THREADEX </p> </blockquote> <p> Are you suggesting that I change Boost.Thread current behavior on working platforms? Sorry, this could mean a lot of regressions. </p> <p> What I can do is add two configuration variables BOOST_THREAD_USE_THREADEX and BOOST_THREAD_DONT_USE_THREADEX in the following way: </p> <pre class="wiki">#if defined BOOST_THREAD_USE_THREADEX &amp;&amp; defined BOOST_THREAD_DONT_USE_THREADEX #error "BOOST_THREAD_USE_THREADEX and BOOST_THREAD_DONT_USE_THREADEX can not be defined simultaneously" #elif ! defined BOOST_THREAD_USE_THREADEX &amp;&amp; ! defined BOOST_THREAD_DONT_USE_THREADEX #if defined BOOST_HAS_THREADEX #define defined BOOST_THREAD_USE_THREADEX #endif </pre><p> and change the uses of BOOST_HAS_THREADEX in Boost.Thread by BOOST_THREAD_USE_THREADEX. </p> <p> Then in your case you would need to define BOOST_THREAD_DONT_USE_THREADEX to build Boost. </p> <p> </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Fri, 20 Sep 2013 06:48:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:9</guid> <description> <blockquote> <p> This can be done, see bellow. The major drawback is that you this forces you to have your own Boost installation. Are you sure there is no such a macro or set of macros (versions) that tell that _beginthreadex is not defined? </p> </blockquote> <p> Yes it is ugly and not very convenient but there is no other choice we can achieve it without introducing another library(.lib file) which would contain custom _beginthreadex implementation and would be linked if native one is absent. I've done it that way for now in my application: I just provided stub implementation of _beginthreadex for my app and it works. </p> <p> Why there is no other choice? Because you can create Metro app as well as any other app for Windows 8.1. And existence of _beginthreadex depends on Visual Studio project type(more accurately on compiler switch). So one may want to create Metro app and for that he needs boost with custom _beginthreadex. But one may also have some desktop app he's working on so for that app he would better use boost with native _beginthreadex. </p> <p> Actually Boost.Thread is almost useless for Metro Apps since they have strict rules of what can be used with it and current Boost.Thread doesn't conform(at least boost::thread). So there is no point to use boost::thread with WinRT(Metro). Yet many other boost libs depends on Boost.Thread and it gives a pain. </p> <blockquote> <p> Are you suggesting that I change Boost.Thread current behavior on working platforms? Sorry, this could mean a lot of regressions. </p> </blockquote> <p> Yes, I meant exactly it. I don't think it will introduce any regression since it may be integrated quite smoothly since the only change which is needed is to change macro name and change <strong>ifndef</strong> to <strong>ifdef</strong>. Moreover WinCE not a popular platform these days, if it still alive. But I'm sure you know what is better since you're a maintainer. </p> <p> Your proposition also seems to be a solution for the issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 20 Sep 2013 21:26:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:10</guid> <description> <p> Maybe I have not understood you correctly. Note that I'm not a Windows programmer and I don't know even what a Metro application is. </p> <p> Please could you provide a patch. I will apply it if your patch doesn't changes the behavior on the working platforms. </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Tue, 24 Sep 2013 13:39:50 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/9124 https://svn.boost.org/trac10/ticket/9124 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">visualc.hpp.patch</span> </li> </ul> <p> simple patch </p> Ticket ixSci <beholder@…> Tue, 24 Sep 2013 13:43:01 GMT <link>https://svn.boost.org/trac10/ticket/9124#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:11</guid> <description> <p> BOOST_FOR_WINRT macro should be defined during compilation by an user explicitly. I believe this macro could be used in other boost libs as well. Since Boost.Thread not the only one library which has some incompatibility with Windows 8 sandboxed applications. Also it could be used in the future if Boost.Thread would be fully ported for WinRT API </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 26 Sep 2013 17:54:48 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/9124#comment:12 https://svn.boost.org/trac10/ticket/9124#comment:12 <ul> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">config</span> </li> </ul> <p> Well, I would move it to Boost.Config to see what they think. </p> Ticket viboes Sun, 29 Sep 2013 08:21:25 GMT owner, status changed https://svn.boost.org/trac10/ticket/9124#comment:13 https://svn.boost.org/trac10/ticket/9124#comment:13 <ul> <li><strong>owner</strong> changed from <span class="trac-author">viboes</span> to <span class="trac-author">John Maddock</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket John Maddock Sun, 29 Sep 2013 11:38:31 GMT <link>https://svn.boost.org/trac10/ticket/9124#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:14</guid> <description> <p> I've done some digging, and: </p> <ul><li>It appears that <code>__cplusplus_winrt</code> is defined when building with /ZW can you confirm that? </li><li>Simply disabling BOOST_HAS_THREADEX doesn't seem the correct solution: calling that API is required in order to correctly initialize the C++ runtime library, in any case <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx</a> indicates that <strong>all</strong> the Windows Thread API functions are missing/deprecated on that platform, and that the C# components should be used instead :( </li></ul><p> So I don't really see that there's a quick/easy fix here. Maybe we should disable threading support altogether for that platform? Except that would disable thread safety/synchronization support as well, and I don't see mutex support in the C# primitives - is code supposed to still use the regular Windows API's for that? Or perhaps we should be using <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/dd492843.aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/dd492843.aspx</a>? Either way it seems like Boost.Threads would need a significant rewrite to support this stuff. </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Sun, 29 Sep 2013 13:49:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:15</guid> <description> <p> I confirm there is such a macro(<span class="underline">cplusplus_winrt) when building with /ZW. </span></p> <p> The solution proposed is not meant to be fully fledged solution for using boost.thread with WinRT but just to get it linking with project with WinRT. Currently you can't link against boost.thread(and as well at least with boost.locale, <a class="missing ticket">issue:https://svn.boost.org/trac/boost/ticket/9125</a>). So the main purpose of the patch is to allow at least link against boost. Since a few other libraries depends on boost.thread you just can't use them also(e.g. boost.log). </p> <p> You get it slightly wrong the API doesn't have any C# components. They are pure C++ they are just like COM. It is away Widows API evolving for C-like to C++-like. The only restriction is that WinRT could be used with so called Metro(windows store) applications only. </p> <p> And it is the very reason you can't count on any system macros: you don't have true new platform actually. You just have a sandboxed platform inside existing WIndows platform. So one can use boost to build Metro app and Win32 app on the same machine. But to have it right one will have to use separate boost bulds anyway: one for win32 and one for winrt. It is just a reality. There is no way to fix it by using system macros. I hope my explanation will shed some light. </p> <p> That is why I proposed this patch. Real solution for the boost.thread problem is to add WinRT support to the boost.thread. Or even add not a WinT support but just C++11 support underneath. Since every Visual Studio which could be used to write WinRT does have C++11 thread support. But still it is whole another story. Right now it should be at least possible to link against boost.thread. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 13 Dec 2013 10:02:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:16</guid> <description> <p> I'm still wary of this patch: disabling use of <code>__beginthreadex</code> will presumably cause your program to crash at runtime due to an incorrectly initialized std lib if you create any threads? I still feel that someone with access to this MSVC build option needs to provide a proper patch that allows the thread lib tests to pass, otherwise we're just thrashing around in the dark breaking random stuff... </p> </description> <category>Ticket</category> </item> <item> <author>ixSci <beholder@…></author> <pubDate>Fri, 13 Dec 2013 11:22:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:17</guid> <description> <p> johnmaddock, honestly I don't know how to explain it better... std lib for Windows Store application DOESN'T HAVE _ _beginthreadex and it DOESN'T participate in any initialization. So basically you can't use Boost.Thread with Windows Store application anyway. To make it possible to use Boost.Thread with Windows Store application Boost.Thread should be changed as I said above(either implement boost.thread with WinRT API or use standard std::thread inside it). The patch I provided simply allows to compile boost for Windows Store application. I don't know maybe it would be better to add static_assert to warn anyone who tries to use boost::thread that it is unsupported. </p> <p> Anyway this patch didn't mean to add support for Windows Store apps, only to add the possibility to compile boost at all. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 13 Dec 2013 12:09:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9124#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9124#comment:18</guid> <description> <p> I understand the issue and your frustration. </p> <p> What I'm against is changing Boost.Thread in a way that allows it to compile, but causes hidden/silent/unpredictable breakages at runtime. </p> <p> Note that you still have the option to either define BOOST_DISABLE_THREADS when building to build single threaded versions of Boost libraries, or of changing boost/config/user.hpp to modify the Config setting for your specific case. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Tue, 31 Jul 2018 18:32:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9124#comment:19 https://svn.boost.org/trac10/ticket/9124#comment:19 <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">obsolete</span> </li> </ul> Ticket