Home > Backend Development > C++ > Why Does `std::stoi` Not Exist in MinGW with gcc 4.6.1?

Why Does `std::stoi` Not Exist in MinGW with gcc 4.6.1?

Linda Hamilton
Release: 2024-10-29 05:54:30
Original
276 people have browsed it

Why Does `std::stoi` Not Exist in MinGW with gcc 4.6.1?

std::stoi Does Not Exist in MinGW

When compiling a program using std::stoi on MinGW with gcc 4.6.1, an error message may occur stating that "std::stoi is not a member of 'std'". This occurs despite the function's availability in newer versions of gcc.

The Cause:

MinGW's non-standard declaration of the vswprintf function defines the macro _GLIBCXX_HAVE_BROKEN_VSWPRINTF, which disables the conversion functions, including std::stoi.

Workaround:

Modify the header files included with MinGW by commenting out the macro on line 2754 of .../lib/gcc/mingw32/4.6.1/include/c /bits/basic_string.h. Additionally, add the macro back around lines 2905 to 2965, excluding the references to std::vswprintf. While this workaround enables the conversion functions, it prevents the use of std::to_wstring functions.

The above is the detailed content of Why Does `std::stoi` Not Exist in MinGW with gcc 4.6.1?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template