C++ under Windows ("stoi" under MinGW)

Discussion in 'C++' started by Stefan Ram, Mar 16, 2014.

  1. Stefan Ram

    Stefan Ram Guest

    It seems that one cannot call »::std::stoi« under MinGW because it
    will break existing programs using the Windows versions of [v]swprintf.

    Well, if I do not want to use Windows functions, but just want to
    run portable C++ code, what can I do under Windows?

    Can one download a recent g++ executable for the Windows command
    line (it does not have to support special Windows libaries)?

    Is there an explanantion how to call the existing g++.exe of MinGW
    to use it as a plain C++ compiler without the Windows support of MinGW?

    I just want to run portable C++ code under Windows,
    and without »::std::stoi« it's not C++.
    Stefan Ram, Mar 16, 2014
    1. Advertisements

  2. Stefan Ram

    Öö Tiib Guest

    Can you explain what is the issue and what has std::vswprintf to do
    with std::stoi?

    If there is some defect somewhere in library of some implementation
    then you can report it to makers of library of implementation.

    (May be it was just me but) I did not understand what you are complaining.
    Öö Tiib, Mar 16, 2014
    1. Advertisements

  3. Stefan Ram

    Stefan Ram Guest

    There already are dozens of web pages about this issue.
    The bug report was closed long ago, but the problem persists.
    Stefan Ram, Mar 16, 2014
  4. Stefan Ram

    Öö Tiib Guest

    Yes I see that there is closed/fixed bug like that:


    They say that they fixed it and how they did and I don't understand what
    is the issue.
    Öö Tiib, Mar 16, 2014
  5. Stefan Ram

    K. Frank Guest

    Hi Stefan!

    I don't see any problem with naive use of stoi and mingw-w64.

    == stoi_tst.cpp ==

    #include <iostream>
    #include <string>

    int main (int argc, char* argv[]) {
    std::string s123{" 123 "};
    int i123 = std::stoi (s123);
    std::cout << "i123 = " << i123 << std::endl;

    C:\> g++ --version
    g++ (rubenvb-4.8-stdthread) 4.8.1 20130324 (prerelease)

    C:\> g++ -std=gnu++11 -o stoi_tst stoi_tst.cpp

    C:\> stoi_tst
    i123 = 123

    More detail about the problem you're seeing would be
    helpful. (And if we can't resolve your problem easily,
    it would probably make sense to address further questions
    to the mingw (or mingw-w64) mailing list.)

    Good luck.

    K. Frank
    K. Frank, Mar 17, 2014
  6. Stefan Ram

    Stefan Ram Guest

    The problem exists only with the 32-bit version of MinGW.
    But in the meantime I found a solution. I am now using
    »TDM-GCC« which does not have the problem. Thanks for all
    the answers here in the newsgroup!
    Stefan Ram, Mar 17, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.