{"id":1624,"date":"2013-07-13T19:01:00","date_gmt":"2013-07-13T10:01:00","guid":{"rendered":"http:\/\/mattyan.net\/blog\/?p=1624"},"modified":"2013-07-13T19:01:00","modified_gmt":"2013-07-13T10:01:00","slug":"clang3-2-1%e3%81%a7stdthread%e3%82%92%e4%bd%bf%e3%81%86%e6%99%82%e3%81%ae%e6%b3%a8%e6%84%8f","status":"publish","type":"post","link":"https:\/\/mattyan.net\/blog\/?p=1624","title":{"rendered":"clang3.2.1\u3067std::thread\u3092\u4f7f\u3046\u6642\u306e\u6ce8\u610f"},"content":{"rendered":"<p>\u500b\u4eba\u7684\u30e1\u30e2\u66f8\u304d\u3002<br \/>\nUbuntu13.04\u306eclang++ version 3.2.1\u3067std::thread\u3092\u4f7f\u3046\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3002<br \/>\n[cpp]<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;thread&gt;<br \/>\nvoid threadFunction(){<br \/>\n        for(int i = 0; i &lt; 10000; i++){<br \/>\n                std::cout &lt;&lt; &quot;thread &quot; &lt;&lt; i &lt;&lt; std::endl;<br \/>\n        }<br \/>\n        return;<br \/>\n}<br \/>\nint main(){<br \/>\n        std::thread thr(threadFunction);<br \/>\n        for(int i = 0; i &lt; 10000; i++){<br \/>\n                std::cout &lt;&lt; i &lt;&lt; std::endl;<br \/>\n        }<br \/>\n        std::cout &lt;&lt; &quot;thread end&quot; &lt;&lt; std::endl;<br \/>\n        thr.join();<br \/>\n        return 0;<br \/>\n}<br \/>\n[\/cpp]<br \/>\n\u3067\u3001\u3053\u308c\u3092<\/p>\n<pre>mattyan@U24E:~$clang++ -g -std=c++11 threadtest.cpp -o threadtest -lpthread<\/pre>\n<p>\u3067\u30d3\u30eb\u30c9\u3057\u3066\u5b9f\u884c\u3057\u3088\u3046\u3068\u3057\u305f\u3089\u3001<\/p>\n<pre>\nmattyan@U24E:~$ .\/threadtest\npure virtual method called\nterminate called without an active exception\n\u4e2d\u6b62 (\u30b3\u30a2\u30c0\u30f3\u30d7)\n<\/pre>\n<p>\u3068\u51fa\u3066\u4f8b\u5916\u3092\u5410\u3044\u3066\u843d\u3061\u305f\u3002<br \/>\n\u30b0\u30b0\u3063\u3066\u307f\u305f\u3068\u3053\u308d\u3069\u3063\u304b\u3057\u3089\u30d0\u30b0\u3063\u3066\u308b\u3089\u3057\u304f\u3066<\/p>\n<pre>mattyan@U24E:~$ clang++ -g -std=c++11 threadtest.cpp -o threadtest -lpthread -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8\n<\/pre>\n<p>\u3053\u3046\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3089\u3057\u3044\u3002<br \/>\n\u8ffd\u8a18:MinGW gcc 4.7.2\u306fthread\u304c\u5c01\u9396\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3060\u2026boost::thread\u5b89\u5b9a\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u500b\u4eba\u7684\u30e1\u30e2\u66f8\u304d\u3002 Ubuntu13.04\u306eclang++ version 3.2.1\u3067std::thread\u3092\u4f7f\u3046\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3002 [cpp] #include &lt;iostream&gt; #include &#038;lt &hellip; <a href=\"https:\/\/mattyan.net\/blog\/?p=1624\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">clang3.2.1\u3067std::thread\u3092\u4f7f\u3046\u6642\u306e\u6ce8\u610f<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1],"tags":[],"class_list":["post-1624","post","type-post","status-publish","format-standard","hentry","category-3","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1624"}],"version-history":[{"count":0,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1624\/revisions"}],"wp:attachment":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}