0

I'm working on a project using Eclipse for C++. Currently I need to use structures such as tuples and hashes. When looking for it on the cplusplus site i came with these:

http://www.cplusplus.com/reference/tuple/tuple/?kw=tuple

The point is, following the example code on the site when trying to compile I get an error, which says, for example, that tuple is not defined. Looking more closely, the c++ sites says these features work on revision 11 and newer. Maybe this can be my problem since I have no idea how to check my version.

How do I get to work with the last revision? I'd really help me a lot not having to implement these kind of structures from scratch.

EDIT: i did g++ --version on the console and got:

g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

Im using Ubuntu 12.04 with Eclipse C/C++ Kepler SR2

EDIT with answer:

Tu use the c11 standard, gcc 4.7 is needed. Refer to this link: http://www.swiftsoftwaregroup.com/upgrade-gcc-4-7-ubuntu-12-04/

to install it.

Fefee
  • 1
  • 2

1 Answers1

1

compile with std=c++11, like g++ -std=c++11 program.cpp . tuple is indeed newly introduced in C++11, but you can use maps and sets in C++03 (the unordered versions are again a new feature of the standard library that comes with C++11). In eclipse, go to project properties, C/C++ Build/Settings/C++ compiler/Miscellaneous, then add the -std=c++11 flag

vsoftco
  • 55,410
  • 12
  • 139
  • 252
  • Ok, I thought that one knows how to change the compiler. Go to project properties, `C/C++ Build/Settings/C++ compiler/Miscellaneous`, then add the `-std=c++11` flag – vsoftco May 19 '14 at 00:37
  • I get an error with this. It says cc1plus: error: unrecognized command line option ‘-std=c++11’ – Fefee May 19 '14 at 01:09
  • Then it means your compiler doesn't support C++11. What platform are you using? Can you open a terminal and type `g++ --version` (or `c++ --version`)? – vsoftco May 19 '14 at 01:10
  • g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Im using Ubuntu 12.04 with Eclipse C/C++ Kepler SR2 – Fefee May 19 '14 at 01:51