Note that there are some explanatory texts on larger screens.

plurals
  1. POISO C++ forbids declaration of ‘tuple’ with no type
    primarykey
    data
    text
    <p>When trying to compile a simple class (<code>g++ myclass.cpp</code>), I get the following error:</p> <pre><code>ISO C++ forbids declaration of ‘tuple’ with no type </code></pre> <p>I searched for this problem, and in most cases people seemed to forget <code>std::</code> or including <code>&lt;tuple&gt;</code> in the header. But I have both. Here is my code:</p> <p><strong>myclass.h</strong></p> <pre><code>#ifndef MYCLASS #define MYCLASS #include &lt;iostream&gt; #include &lt;tuple&gt; class MyClass { std::tuple&lt;bool, int, int&gt; my_method(); }; #endif </code></pre> <p><strong>myclass.cpp</strong></p> <pre><code>#include "myclass.h" using namespace std; tuple&lt;bool, int, int&gt; MyClass::my_method() { return make_tuple(true, 1, 1); } </code></pre> <p>If I do the same using <code>pair</code> instead, leaving out the second <code>int</code> and including <code>&lt;set&gt;</code>, it works.</p> <p>What am I missing?</p> <p><strong>EDIT:</strong></p> <p>Here is the full output:</p> <pre><code>$ g++ myclass.cpp -o prog In file included from myclass.cpp:1: myclass.h:7: error: ISO C++ forbids declaration of ‘tuple’ with no type myclass.h:7: error: invalid use of ‘::’ myclass.h:7: error: expected ‘;’ before ‘&lt;’ token myclass.cpp:5: error: expected constructor, destructor, or type conversion before ‘&lt;’ token </code></pre> <p></p> <pre><code>$ g++ --version i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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