Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Can't use C++11 features?('stoi' was not declared in this scope (when trying to use the C++11 string library))
Can't use C++11 features? [message #773607] Sun, 01 January 2012 23:37 Go to next message
Eclipse UserFriend
Ahoy. I've just (on Windows 7) downloaded and installed MinGW, MSys, changed my environment path, and maybe some other stuff and got Eclipse to compile and run my projects.

I'm trying to use C++11 features, which, at a guest lecture, Bjarne Stroustrup indicated should already be available in current implementations of gcc and hence, MinGW and all that, but, I can't. If I simply attempt to #include <unordered_set>, I can compile and get my program to run by adding the compiler option 'std=c++0x', which I did successfully (though I've not actually tried using one of these containers). What troubles me though, is that I can't access the new string functions that should be implemented, things like stoi, as documented here: en.cppreference.com/w/cpp/string/basic_string/stol

I've used the precise example they list on that page to no avail. I get the error: ..\src\main.cpp:17:27: error: 'stoi' was not declared in this scope

Have I done something wrong with Eclipse, or am I wrong in the assumption that this feature should already be implemented in the compiler?

Edit:

For what it's worth, I tried compiling directly from the command line with gcc and got the same error...

Here's a question... can any of you successfully compile and run a program using stoi?

[Updated on: Mon, 02 January 2012 13:11] by Moderator

Re: Can't use C++11 features? [message #774055 is a reply to message #773607] Tue, 03 January 2012 02:17 Go to previous messageGo to next message
Eclipse UserFriend
I think the example is wrong. You should either write
std::stoi(test)
or add the line
using namespace std
before main.
Re: Can't use C++11 features? [message #775264 is a reply to message #774055] Thu, 05 January 2012 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Already had using namespace std; in there, if not on the example page, in my code. Thanks though. Still not working.
Re: Can't use C++11 features? [message #776779 is a reply to message #775264] Mon, 09 January 2012 04:10 Go to previous message
Eclipse UserFriend
It seems that MinGW does not support std::stoi yet (at least not version 4.6.1). See http://stackoverflow.com/questions/8542221/stdstoi-doesnt-exist-in-g-4-6-1-on-mingw

There is a workaround mentioned.
Previous Topic:Shared coding style in CDT
Next Topic:Function name mangling
Goto Forum:
  


Current Time: Fri Nov 07 06:48:05 EST 2025

Powered by FUDForum. Page generated in 0.03786 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top