ISO C++ forbids declaration of ‘tuple’ with no type

With gcc 4.2, tuple was in namespace std::tr1. You must include <tr1/tuple> and specify your method more or less like this

#ifndef MYCLASS
#define MYCLASS

#include <tr1/tuple>

class MyClass {
    std::tr1::tuple<bool, int, int> my_method();
};

#endif

Although, as others already suggested, updating to a more recent gcc might be more appropriate.


Update! We're on GCC 4.7 these days.

GCC 4.2.1 is from all the way back on 18th July, 2007. There is only a remote chance that it supports any features from what became C++11.

That said, it may provide some in std::tr1 (i.e. std::tr1::tuple<T1, T2, ...>), which is where some of the C++11 features lived in the time before standardisation, though off the top of my head these were introduced to GCC only in 4.4.


GCC 4.2.1 shipped with every mac is outdated. It will not recognize the C++11.

You need to compile your code using: c++ instead of g++ which calls clang, which is the officially updated compiler on mac.

c++ -std=c++11 -stdlib=libc++ myclass.cpp -o prog 

You are required to link against libc++ which is clang lib which knows about c++11 features instead of the default libstdc++ used by gcc.