Most of us when port something with recent gcc, offten meet with issues when one or another function bring errors like "error: ‘func()’ is not a member of ‘std’".
Lately found that not only stoi(), but also stod(), stof(), stoul() and stol() can't be used as "not a members of std".
@All At moment found solution myself, a bit not clean as it , but still, maybe someone will have needs for:
To make those functions works without any code changes, you can add "-D_GLIBCXX_USE_C99_STDLIB" to makefile when compile objects, as well, as on linking stage you will have needs to add -lstdc++ too.
For example that test case:
#include <cstdio>
#include <thread>
#include <future>
#include <cstdio>
#include <unistd.h>
enum MapParameterIndices : int
{
LEVELPARAM_CHANCE_SECRET,
LEVELPARAM_CHANCE_DARKNESS,
LEVELPARAM_CHANCE_MINOTAUR
};
Didn't work when we just do "ppc-amigaos-gcc test.cpp", and bring usual " error: ‘stoi’ is not a member of ‘std’", but then, if we do:
ppc-amigaos-gcc -D_GLIBCXX_USE_C99_STDLIB test.cpp , then object compiles fine, just linking fail, which we fix by adding -lstdc++ (together with our -athread=native and -lpthread).
So to summorize to compile that test case and make it works we do:
Of course we can use #define _GLIBCXX_USE_C99_STDLIB 1 in source code as well, or (by logic) in that c++config.h in our includes, but that sometime may not work, as seems some other includes also redefine it somehow.
That at least help with functions i check: stoi, stol, stod, stoul & stof. All compiles and links fine without code changes.
@Hans If use clib2, then your issue about to_string() is gone, yes, but with stoi() and co, issue still here even with clib2.
My bet is not only newlib headers guilty (maybe with case of to_string() only newlib ), but also pure gcc includes as well (that c++config.h file, etc).