Re: how do i get to_string to work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ben,
On Sat, Oct 16, 2010 at 01:20:35PM +0100, Benjamin Czaczkes wrote:
> thanks for a very quick response
> here is a minimal program
> 
> #include <iostream>
> #include <string>
> using namespace std;
> int main()
> {
>   cout << to_string(12)
>   return 0;
> }
> to_string is actually declared  in basic_string.h as
> [...]
yes, but: That is part of the up-coming C++0x standard (just read the
file basic_string.h a file lines before:
#if (defined(__GXX_EXPERIMENTAL_CXX0X) && ....)

So: You have to tell g++ to compile your code using the standard C++0x;
if not, he ignores those lines.
That's done by adding the option "-std=c++0x" when you call the
compiler.

With that, your code compiles and runs (after adding a missing ";" in
your example ;-)) here. 
I tried it on g++ 4.6.0 (20100916), but your compiler should also be
modern enough (as you have already the necessary functions in your
header files).

HTH,

Axel


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux