cygwin g++ std::stoi "error: ‘stoi’ is not a member of ‘std

前端 未结 4 1231
情歌与酒
情歌与酒 2020-11-30 09:55

I have:

-cygwin 1.7.25 on windows 7/32bit

-g++ --version --> g++ (GCC) 4.8.2

-libstdc++.a --> gcc-g++-4.8.2-1

Tried to make a c++ Hello Wor

相关标签:
4条回答
  • 2020-11-30 10:28

    stoi works correct only on mingw64 for me. If you use Codeblocks, don't forget to check if your projects compiler is set to mingw64.

    0 讨论(0)
  • 2020-11-30 10:33

    That's a bug, possibly an incomplete port of some library code to cygwin (it's a cplusplus11 feature) - some stuff has to be changed after all. Make sure to report it.

    The solution is easy of course: #include <cstdlib> strtol(s.c_str(),0,10);

    www.cplusplus.com/.../strtol

    A similar mingw bug is mentioned also here

    std::stoi doesn't exist in g++ 4.6.1 on MinGW

    0 讨论(0)
  • 2020-11-30 10:34

    The compiler is not being taken seriously. On windows your best bet is to probably use visual studio, as it is always kept up to date . The bug here is that the macro defs are wrong to begin with. The problem starts from iomanip.h and iosbase . So they would have to changed all of there code. There are user made patches for this but I would not trust them at all, as they may contain even more bugs then the original copies. But it's up to you , I just stick with visual studio express edition.

    0 讨论(0)
  • 2020-11-30 10:37

    I have the same problem yesterday. "error: 'stoi' is not a member of 'std'."

    First, I made sure c++11 was enabled. Then, I updated the g++ compiler to the newest version. After that, this error disappeared.

    0 讨论(0)
提交回复
热议问题