Page 1 of 1
to_string
Posted: Mon Aug 07, 2017 8:16 am
by permal
Hi,
std::to_string(...) is supposed be included in C++11 via <string.h>, but it seems to not be included when compiling with the Xtensa port of GCC. Am I missing something, or is it actually not available? If not, can it be made available?
Re: to_string
Posted: Mon Aug 07, 2017 9:54 am
by ESP_igrr
This incompatibility between libstdc++ and newlib seems to be discussed here:
https://gcc.gnu.org/ml/libstdc++/2013-10/msg00245.html
It seems that rebuilding libstdc++ is required, and `__STDC_VERSION__` has to be tweaked while libstdc++ is going through ./configure step, so that newlib provides vprintf declaration.
Re: to_string
Posted: Mon Aug 07, 2017 12:58 pm
by permal
Oh, what a hassle
Re: to_string
Posted: Mon Aug 07, 2017 2:16 pm
by kolban
As a possible alternative, one might be able to use std::stringstream.
Once can then perform logic similar to:
std::string stream ss << "Hello world" << myDouble << " " << myInt;
std::string s = ss.str();
Re: to_string
Posted: Mon Aug 07, 2017 3:04 pm
by permal
Yes, stringstream is an alternative, though it is rather heavy just to convert a single integer into an alphanumeric.