Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I try to use emplace() function for an unordered_map and compiler says that no such function exists.

I put -std=c+11 and it says cc1plus.exe: error: unrecognized command line option '-std=c+11'

Can i somehow use C++11 functionality with mingw?

share|improve this question
4  
Try c++11 instead of c+11 – Andy Prowl Apr 21 at 20:58
Either that, or try c++0x – Charles Salvia Apr 21 at 21:05
Neither works (i allready have c++0x ON) – Petros Drakoulis Apr 21 at 21:23
2  
What version is your MinGW (You can check with gcc -v)? std=c++11 was introduced relatively recently. – milleniumbug Apr 21 at 22:03
1  
@PetrosDrakoulis: Then maybe it's not available on that version. MinGW is up to 4.7.2 now. – Nicol Bolas Apr 22 at 5:42
show 4 more comments

1 Answer

From the GCC documentation

C++0x was the working name of a new ISO C++ standard, which was then released in 2011 as C++11 and introduces a host of new features into the standard C++ language and library. This project seeks to implement new C++11 features in GCC and to make it one of the first compilers to bring C++11 to C++ programmers.

C++11 features are available as part of the "mainline" GCC compiler in the trunk of GCC's Subversion repository and in GCC 4.3 and later. To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well.

So, for gcc 4.3 through 4.6 use -std=c++0x, for later version use -std=c++11. Library support for map::emplace was added in gcc 4.8

share|improve this answer
same error: 'class std::unordered_map<std::basic_string<char>, dictionaryWord>' has no member named 'emplace' – Petros Drakoulis Apr 22 at 13:40
I have come to believe that i can not use c++ 11, or at least all of it, with 4.6. – Petros Drakoulis Apr 22 at 13:47
You will need gcc 4.8 to use map::emplace, see e.g. this question – rhalbersma Apr 22 at 14:45
The project i try to compile for windows, was made in Linux Gcc 4.7.2 a month ago. There is emplace() in linux gcc 4.7.2 – Petros Drakoulis Apr 22 at 18:19
@PetrosDrakoulis That's surprising because the gcc 4.7.2 docs says that emplace is missing for map. See also ideone.com/dqScM9 Safe bet is to install MinGW 4.8, e.g. from nuwen.net/mingw.html – rhalbersma Apr 22 at 18:57
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.