Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature: (5 Items)
   
GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature  
Hi,

I am trying to build the Botan library (botan.randombit.net). It requires C++11 compliant compiler, thus I upgraded my 
QNX 650 to use GCC 4.8.3.

To build the library I do the following:

./configure.py \
--os=qnx \
--cpu=x86 \
--cc=gcc \
--cc-bin=ntox86-g++-4.8.3

make install

But got an error:

build/include/botan/exceptn.h: In constructor 'Botan::Invalid_Key_Length::Invalid_Key_Length(const string&, std::
size_t)':
build/include/botan/exceptn.h:89:24: error: 'to_string' is not a member of 'std'

Thus my question is how to enable the to_string() feature?
Re: GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature  
As Mario had mentioned in the other thread, this is caused by _GLIBCXX_USE_C99 not being defined.

The configure script for libstdc++-v3 will check for c99 functions with -std=c++98 set, but our system headers won't 
expose the c99 functions in this case.

This can be fixed by patching the system headers to expose the c99 functions  regardless of the c++ standard specified 
and rebuilding gcc.

It might also be possible to edit the configure script to use -std=c++0x and rebuild gcc, but I cannot guarantee that 
won't cause problems in the headers outside c++0x/c++11.

Then there is the hacky solution which is to just force _GLIBCXX_USE_C99 to be defined and hope for the best. I wouldn't
 really recommend this and cannot guarantee this will not cause other problems, but to each their own.
Re: GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature  
Thanks Michael for the answer.

> This can be fixed by patching the system headers to expose the c99 functions  
> regardless of the c++ standard specified and rebuilding gcc.

As I understood, it is a single proper way. But does any instructions exist how to do it?

> Then there is the hacky solution which is to just force _GLIBCXX_USE_C99 to be
>  defined and hope for the best.

You are absolutely right. I tried this way but got the following errors:
/opt/qnx650/target/qnx6/usr/include/c++/4.8.3/bits/basic_string.h:2844:31: error: 'strtoull' is not a member of 'std'
/opt/qnx650/target/qnx6/usr/include/c++/4.8.3/bits/basic_string.h:2953:31: error: 'wcstof' is not a member of 'std'
/opt/qnx650/target/qnx6/usr/include/c++/4.8.3/bits/basic_string.h:2961:31: error: 'wcstold' is not a member of 'std'


Re: GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature  
What we ended up doing is our own header file <custom/string.h> that contains what is needed to support to_string and 
all related functions. It works because everything is inlined, so no need to rebuild a library.

We just need to add #include <custom/string.h> when needed.  I have attached the file in case it helps.

Attachment: Text string.h 4.81 KB
Re: GCC nor 4.8.3 neither 4.9.3 doesn't support to_string C++11 feature  
Thanks. it works.

Just for other users, I put the attached header into <QNX_SDK_HOME>/target/qnx6/usr/include/c++/4.8.3/custom