|
gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 9:20
#1 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 11:31 From Russia
Posts: 5540
|
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". Doing some search, i found few files like this: include\c++\8.2.0\bits\basic_string.h include\c++\8.2.0\ext\vstring.h Where we can see something like this (copy from vstring.h):
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
So, by logic enabling of _GLIBCXX_USE_C99_STDLIB should did the trick and they should work, but sadly just adding #define _GLIBCXX_USE_C99_STDLIB 1 to include/c++/8.2.0/bits/c++config.h do not help. It all just looks like it all can and should works, just in our GCC something not enabled or so.. Or maybe someone have some easy typedef which can be used instead ? Like something of that sort:
#ifdef __amigaos4__
Any ideas and help apprecated, thanks! |
|
|
Re: gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 9:38
#2 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 11:31 From Russia
Posts: 5540
|
@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>
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: ppc-amigaos-gcc -D_GLIBCXX_USE_C99_STDLIB test.cpp -athread=native -lpthread -lstdc++ 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. |
|
|
Re: gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 9:54
#3 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/1/26 21:48 From New Zealand
Posts: 2196
|
@kas1e
Those functions should be available with -std=c++11 (or higher). Hans |
|
_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. https://keasigmadelta.com/ - more of my work |
||
|
Re: gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 10:22
#4 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 11:31 From Russia
Posts: 5540
|
@Hans
Yeah, they should, same as to_string(), basic_string(), etc. But as we all found , it is not. So it can be some misconfiguration or misdefines of our latest gcc. Remember that you have yourself the same problem, just with to_string() not being member of std : https://github.com/sba1/adtools/issues/58 And that one you fix by enabling _GLIBCXX_USE_C99_STDIO. While those ones with stoi and co, fixed by adding by enabling _GLIBCXX_USE_C99_STDLIB. In all cases , not c++11, not gnu++11 or whatever else didn't work. And i am somehow sure it is something in gcc configured wrong. |
|
|
Re: gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 11:47
#5 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/1/26 21:48 From New Zealand
Posts: 2196
|
@kas1e
Ah yes, that's a mistake in the newlib headers. IIRC, it works correctly if you use clib2. Hans |
|
_________________
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. https://keasigmadelta.com/ - more of my work |
||
|
Re: gcc8.2.0 issues with std: stoi, stol, stod, etc. How to fix ? |
Posted on: 7/7 11:57
#6 |
---|---|---|
Home away from home
![]() ![]() Joined:
2007/9/11 11:31 From Russia
Posts: 5540
|
@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). |
|