Visual Studio and c++11

I go back and forth between two computers: one with Windows 7 and one with Windows XP. On Windows 7 I have VS 2012, on Windows XP I can have only VS 2010.

My problem is that I need std::thread class which is part of c++11 standart. Because VS 2012 does not support Windows XP I basicly can't continue writing my program when Win7 machine is unavailable.

Thread class is the only thing I need from c++11. I really need multithreading because I have one thread for body of program and another one for user input.

What would be the solution for Windows XP system? It doesn't have to be universal for XP and Windows 7, different compile options with preprocessor directives would be fine as well.
You could use a different IDE/compiler that supports the thread feature. I prefer code::blocks though why are you using a windows xp computer anyways? You should upgrade it to 7 at least. You could alternatively use boost::thread
Last edited on
I had a look at code::blocks, there are lots of compilers available for it to use, and I guess I need to additionally install them. Which one fully supports c++11?

why are you using a windows xp computer anyways? You should upgrade it to 7 at least


When I'm not at home I have to use an old desktop, it's already pretty buggy, not sure how well it handles Win7.
I would invest in a laptop then :P

Also code::blocks will come with mingw and you just need to turn on the c++11 flag.
Ah, I see. There are a few bizarre compile errors it gives me though, like printf or __int64 undefined, it also complains that my main is not int. Visual Studio was compiling with no errors. Does it need further configuration or I actually need to make some changes in code?
Last edited on
You are probably using non-standard c++ that VS just ignored. since main is always supposed to return int as far as printf are you including the correct header?
I was using <iostream> for VS, after I added stdio.h it stopped pointing me it's undefined.

Wait, if I use VS am I using a some sort of non-standard c++? Is this why it lets me compile with void main?
Most of it is standard but there are a few things that are not like void main and also they have most features other compilers have but not all features
Interesting, what compiler would be the closest to "pure" c++ ?
Try mingw (http://www.mingw.org/), you can still get the latest 32-bit version to run on windows XP (I think). It is as up to date as you can get.
When you compile, it defaults to C++98, I guess this is because of the perception that most people are still using this. To compile successfully you need to use the std flag; for a flag hello .cpp try any of the following in order of how recent the features you need are:
g++ -o hello hello.cpp -> c++98 only
g++ -std=c++11 - o hello hello.cpp -|
g++ -std=c++1x - o hello hello.cpp -|-> support c++11
g++ -std=c++1y - o hello hello.cpp -|

That could be responsible for your errors, but I can't say without seeing the actual errors. I'm not a windows type, but doesnt visualstudio use something like _tmain(int TCHAR**) instead of main(int, char**)?
Also, it uses precompiled headers, and may automatically include other headers you need, even add a "using namespace std" for you, so make sure you manually include all the headers you need, and be aware of the namespace issue.

P.S. I don't use codeblocks, but I'd expect it to have an option of either selecting your c++ dialog, or adding the necessary compile flags to the build command.
Clint Westwood wrote:
what compiler would be the closest to "pure" c++ ?

clang++ version 3.5 or newer, used with "-std=c++14 -pedantic-errors -stdlib=libc++" (could also select c++11, but the farther you go into the obsolete C++ revisions, the less perfect it gets)

Although g++ version 5.0 (also used with "-std=c++14 -pedantic-errors ") finally got good, too.
Last edited on
Thanks, I'll have a look at all this.
Topic archived. No new replies allowed.