Enabling string conversion functions in MinGW

24 August 2012, 11:16 UTC

This patch enables the following list of C++11 functions and templates in the std namespace:
stoi, stol, stoul, stoll, stof, stod, stold, to_string, to_wstring

This assumes you are using the official MinGW distribution.
If you are applying this patch to a version of MinGW GCC later than 4.7, you should examine and apply the patches rather than using the zip file.

Update, 14 September 2012:

All patches here are released in to the public domain, and free for use for any purpose.

Also as stated in an email reply sent to someone regarding gcc bug #52015, this is not a proper MinGW patch. It can break existing programs using the Windows versions of [v]swprintf (as it replaces them with the standard signatures), might(?) cause problems if the functions aren't inlined, and it is applied to post-build MinGW so it cannot be guaranteed that future libstdc++ changes won't make enabling this impossible. The patch is also missing a call to __builtin_va_end.

Tags: MinGW, C++, libstdc++, string, to_string, to_wstring

Author: Julian Smythe