Home  >  Article  >  Backend Development  >  Why is \"stoi\" not a member of \'std\' when compiling with MinGW 4.6.1?

Why is \"stoi\" not a member of \'std\' when compiling with MinGW 4.6.1?

Susan Sarandon
Susan SarandonOriginal
2024-10-29 05:55:02324browse

Why is

std::stoi Issue in MinGW 4.6.1

The error "error: 'stoi' is not a member of 'std'" while compiling with MinGW 4.6.1 stems from a non-standard declaration of vswprintf on Windows.

Explanation:

The GNU Standard Library defines the macro _GLIBCXX_HAVE_BROKEN_VSWPRINTF on this platform. This macro disables certain conversion functions, including std::stoi.

Workaround:

To work around this issue, consider modifying the header files distributed with MinGW:

  1. Remove the !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) macro on line 2754 of .../lib/gcc/mingw32/4.6.1/include/c /bits/basic_string.h.
  2. Re-add the macro around lines 2905 to 2965, which reference std::vswprintf.

Consequences:

This workaround disables std::to_wstring functions but allows other conversion functions to be available.

The above is the detailed content of Why is \"stoi\" not a member of \'std\' when compiling with MinGW 4.6.1?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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