-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
psp-g++ error: ‘to_string’ is not a member of ‘std’ #108
Comments
Could you test on gcc 8.3 at: |
Bundled GCC has been updated to 9.3.0. Could you re-install the toolchain and report whether your problem still exist? |
I wrote this sample code (replaced < and > with ", because GitHub hides what comes after it): #include "iostream" int main() { I compiled it with
|
You can paste CPP code like this: Which is rendered as: int main()
{} Anyways, I did some searching through GCC's #if _GLIBCXX_USE_C99_STDIO
// NB: (v)snprintf vs sprintf.
// DR 1261.
inline string
to_string(int __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int),
"%d", __val); }
inline string
to_string(unsigned __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
4 * sizeof(unsigned),
"%u", __val); }
inline string
to_string(long __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(long),
"%ld", __val); }
inline string
to_string(unsigned long __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
4 * sizeof(unsigned long),
"%lu", __val); }
inline string
to_string(long long __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
4 * sizeof(long long),
"%lld", __val); }
inline string
to_string(unsigned long long __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
4 * sizeof(unsigned long long),
"%llu", __val); }
inline string
to_string(float __val)
{
const int __n =
__gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
"%f", __val);
}
inline string
to_string(double __val)
{
const int __n =
__gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
"%f", __val);
}
inline string
to_string(long double __val)
{
const int __n =
__gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
"%Lf", __val);
}
#endif // _GLIBCXX_USE_C99_STDIO
This could be solved on the psptoolchain side either by updating bundled newlib (although I am not sure of that) or by applying patch removing these guards in few places. Not closing this, as I'm going to actually try updating newlib soon. |
Just to add to this, I ran into this just now with the latest toolchain. |
Also ran into this on diasurgical/devilutionX#1918. Had to change all to_string() calls to snprintf, but that also doesn't exist if using g++. |
@stefanmielke: can you try using newlib from 3.3.0 branch? I never tested it thoroughly, but maybe is enough. |
@carstene1ns, should I just copy the includes, or rebuild the whole toolchain pointing to this branch? |
Unfortunatly this involves rebuilding stage 2 gcc as well. |
It seems to have worked, unfortunately had this side effect:
|
This is unfortunately a side-effect of updating the c library. :/ |
I changed the newlib stage and rebuilt the whole pipeline to get that error. |
Clone just the psplibraries repo and run |
Same error on different libs now:
|
I know it is a bit tedious, but you need the same for every other lib as well. |
That one more did the trick, thanks! Do you have a way to push these changes so we can automate this build? Not sure what I'd need to do here. |
First of all: Thank you for your patience! :) What would need to be done is testing the updated newlib on hardware. Does your project run now? |
Well, it builds, not really runs though (investigating why now) Although it only worked on PPSSPP and crashed on real hardware (I think it's something due to the ways it handles files, as we use StormLib). |
I guess I need to try a basic example then, however, currently no access to a PSP. :/ |
Looks like some of the samples I've tested are working, unfortunately I have no SDL samples to test (btw kernel/fileio is crashing). |
I know this game uses SDL, but I'm not sure if it still builds, since it isn't updated much: https://github.com/sergiou87/open-supaplex |
Same problem mine have. Just a black screen forever (no crashes). Both on PPSSPP and real hardware. It does build without issues. |
Fixed in current toolchain |
Yet I'm compiling with either
std=c++11
orstd=c++14
. There is an implementation of std::to_string under $PSPDEV/psp/include/c++/5.4.0/bits/basic_string.h, but all the code is under the preprocessor directive:#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
. Any way to define _GLIBCXX_USE_C99 by default?I'm using the version 5.4.0 from pull request #90.
In the past I also used the version this repository provides, and I had the same issue.
The text was updated successfully, but these errors were encountered: