Note that there are some explanatory texts on larger screens.

plurals
  1. POC++11 with gcc 4.6.1 on a mac
    primarykey
    data
    text
    <p>I'm new to the mac and trying to get gcc 4.6 working. </p> <p>I installed MacPorts and installed gcc 4.6.1 (by executing <code>sudo port install gcc46</code>). I'm trying to compile a simple test code that compiles fine on Linux (with gcc 4.6.1 and 4.6.2) and Windows, but I'm getting errors that make me thing there is something wrong with the installed libraries.</p> <pre><code>#include &lt;iostream&gt; #include &lt;type_traits&gt; #include &lt;future&gt; struct test { void get() {} }; /*template&lt;typename Func&gt; test async(const Func &amp;f) { f(); return test(); }*/ using namespace std; int main (int argc, const char * argv[]) { auto t1 = async([]() -&gt; int{ cout &lt;&lt; "This is thread 1" &lt;&lt; endl; return 1; }); auto t2 = async([]() -&gt; int { cout &lt;&lt; "This is thread 2" &lt;&lt; endl; return 2; }); std::cout &lt;&lt; "This is the main thread" &lt;&lt; endl; t1.get(); t2.get(); return 0; } </code></pre> <p>The error messages:</p> <pre><code>macbook01:Test fozi$ g++ main.cpp -o test -std=c++0x main.cpp: In function 'int main(int, const char**)': main.cpp:30:6: error: invalid use of incomplete type 'std::enable_if&lt;true, std::future&lt;int&gt; &gt;::type' /opt/local/include/gcc46/c++/future:111:11: error: declaration of 'std::enable_if&lt;true, std::future&lt;int&gt; &gt;::type' main.cpp:30:6: error: unable to deduce 'auto' from '&lt;expression error&gt;' main.cpp:35:6: error: invalid use of incomplete type 'std::enable_if&lt;true, std::future&lt;int&gt; &gt;::type' /opt/local/include/gcc46/c++/future:111:11: error: declaration of 'std::enable_if&lt;true, std::future&lt;int&gt; &gt;::type' main.cpp:35:6: error: unable to deduce 'auto' from '&lt;expression error&gt;' /opt/local/include/gcc46/c++/future: At global scope: /opt/local/include/gcc46/c++/future:150:5: error: 'typename std::enable_if&lt;(! std::is_same&lt;typename std::decay&lt;_Functor&gt;::type, std::launch&gt;::value), std::future&lt;decltype (declval&lt;_Fn&gt;()((declval&lt;_Args&gt;)()...))&gt; &gt;::type std::async(_Fn&amp;&amp;, _Args&amp;&amp; ...) [with _Fn = main(int, const char**)::&lt;lambda()&gt;, _Args = {}, typename std::enable_if&lt;(! std::is_same&lt;typename std::decay&lt;_Functor&gt;::type, std::launch&gt;::value), std::future&lt;decltype (declval&lt;_Fn&gt;()((declval&lt;_Args&gt;)()...))&gt; &gt;::type = std::future&lt;int&gt;]', declared using local type 'main(int, const char**)::&lt;lambda()&gt;', is used but never defined [-fpermissive] /opt/local/include/gcc46/c++/future:150:5: error: 'typename std::enable_if&lt;(! std::is_same&lt;typename std::decay&lt;_Functor&gt;::type, std::launch&gt;::value), std::future&lt;decltype (declval&lt;_Fn&gt;()((declval&lt;_Args&gt;)()...))&gt; &gt;::type std::async(_Fn&amp;&amp;, _Args&amp;&amp; ...) [with _Fn = main(int, const char**)::&lt;lambda()&gt;, _Args = {}, typename std::enable_if&lt;(! std::is_same&lt;typename std::decay&lt;_Functor&gt;::type, std::launch&gt;::value), std::future&lt;decltype (declval&lt;_Fn&gt;()((declval&lt;_Args&gt;)()...))&gt; &gt;::type = std::future&lt;int&gt;]', declared using local type 'main(int, const char**)::&lt;lambda()&gt;', is used but never defined [-fpermissive] </code></pre> <p>Note that if I use my dummy async function it compiles and runs fine.</p> <p>I'm kind of stuck, do I have to install a specific library (version)? How do I do that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload