2013/2/15 Jim Michaels <jmichae3@yahoo.com>
#include <string>
#include <iostream>
#include <stdint.h>
int main(void) {
    int64_t n=5;
    std::string s=std::to_string(n); //http://www.cplusplus.com/reference/string/to_string/
    return 0;
Thu 02/14/2013 23:16:40.04||E:\prj\createfile\createfile-3.28\tests|>type "errto_string"
to_string.cpp: In function 'int main()':
to_string.cpp:6:16: error: 'to_string' is not a member of 'std'

Preliminary note: you do not need to call this function to put an integer into a [f|string]stream. std::to_string is only useful if you need the std::string object for something else later.

The function was not available on MinGW-w64 before GCC 4.8 (4.7.3pre?) and without current MinGW-w64 trunk. JonY made the necessary changes not so long ago. Why there was never a simple fallback in libstdc++ that used a temporary std::stringstream is beyond me though. This is what you can do if it's not available:


The stringstream is not as efficient as a decent implementation based on some printf or manual processing, but as libstdc++ relies on POSIX printf and JonY only fixed that stuff in MinGW-w64 trunk and some as-of-yet unreleased GCC version (4.7.3? and 4.8), this is a valid workaround.

Also: use <cstdint> instead of <stdint.h> (see link above).


Jim Michaels
http://JesusnJim.com (my personal site, has software)
IEC Units: Computer RAM & SSD measurements, microsoft disk size measurements (note: they will say GB or MB or KB or TB when it is IEC Units!):
[KiB] [MiB] [GiB] [TiB]
SI Units: Hard disk industry disk size measurements:
[KB] [MB] [GB] [TB]

Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
Mingw-w64-public mailing list