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

S

Stefan Ram

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++.
 
Ö

Öö Tiib

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

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.
 
S

Stefan Ram

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

There already are dozens of web pages about this issue.
The bug report was closed long ago, but the problem persists.
 
K

K. Frank

Hi Stefan!

There already are dozens of web pages about this issue.
The bug report was closed long ago, but the problem persists.

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
 
S

Stefan Ram

K. Frank said:
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.)

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!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top