Using std::stoi and std::stod with clang++ in Windows

1.2k views Asked by At

I am trying to compile some code in Windows with clang++ using this command line

clang++ -std=c++11 *.cpp -Wall

but I get the following:

Datetime.cpp:74:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(1)),
                        ~~~~~^
Datetime.cpp:75:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(2)),
                        ~~~~~^
Datetime.cpp:76:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(3)),
                        ~~~~~^
Datetime.cpp:77:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(4)),
                        ~~~~~^
Datetime.cpp:78:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(5)),
                        ~~~~~^
Datetime.cpp:79:9: error: no member named 'stoi' in namespace 'std'
                        std::stoi(match.str(6))
                        ~~~~~^
6 errors generated.
fileReader.cpp:21:47: error: no member named 'stod' in namespace 'std'
                    scoe.semiMajorAxis = std::stod(line, nullptr);
                                         ~~~~~^
fileReader.cpp:24:53: error: no member named 'stod' in namespace 'std'
                    scoe.orbitalEccentricity = std::stod(line, nullptr);
                                               ~~~~~^
fileReader.cpp:27:58: error: no member named 'stod' in namespace 'std'
                    scoe.orbitalInclination = dtr * std::stod(line, nullptr);
                                                    ~~~~~^
fileReader.cpp:30:57: error: no member named 'stod' in namespace 'std'
                    scoe.argumentOfPerigee = dtr * std::stod(line,nullptr);
                                                   ~~~~~^
fileReader.cpp:33:63: error: no member named 'stod' in namespace 'std'
                    scoe.rightAscOfAscendingNode = dtr * std::stod(line...
                                                         ~~~~~^
fileReader.cpp:36:51: error: no member named 'stod' in namespace 'std'
                    scoe.trueAnomaly = dtr * std::stod(line, nullptr);
                                             ~~~~~^
fileReader.cpp:70:41: error: no member named 'stod' in namespace 'std'
            atmosDensity.push_back(std::stod(line, nullptr));
                                   ~~~~~^
7 errors generated.

(I have included in those files)

The code compiles and works fine in Visual Studio 2013. How can I make it work with clang++?

1

There are 1 answers

4
Shoe On

You have to include the <string> header and compile with -std=c++11 or -std=c++14 or anything above that and remember to select the proper standard library with -stdlib=libc++.