Does Visual C++ 2010 support the C++11 threads library?
Asked Answered
W

2

7

I am using Visual C++ 2010. Does it support the C++11 threads library, such that I could compile the code in this question?

If not, what library can I use that would support this?

Waldron answered 25/10, 2010 at 7:4 Comment(0)
T
10

Visual C++ 2010 does not provide the C++11 thread support or atomics libraries.

If you want to use that code in Visual C++ 2010, you'll need to use a third-party implementation of those libraries. One option is just::thread; it's not free, but I have a copy and am quite pleased with it.

Alternatively, you can use another cross-platform threads library like Boost.Thread or OpenThreads or one of the native Windows threads libraries. Any of these options will probably require changes to the code in order to run.

Note that Visual C++ 11 will support these libraries, and they are included in the Visual C++ 11 Beta.

Tuner answered 25/10, 2010 at 7:8 Comment(3)
And a free kinda-equivalent is Boost.Thread and Boost.Atomic (unofficial).Arleta
@GMan: True; one major thing that Boost.Thread is (to the best of my knowledge) missing is an equivalent to std::async, which is the greatest thing since the creation of the destructor.Tuner
Yeah, it does have futures though, so it's not too far out of reach.Arleta
P
1

VC++ supports special embedded syntax OpenMP (http://msdn.microsoft.com/en-us/library/tt15eb9t(VS.80).aspx) - note, that g++ is also suports it, so you can get cross platform code.

Pentastyle answered 25/10, 2010 at 7:20 Comment(4)
how is the question related to OpenMP?Ascanius
@Ascanius - OpenMP embeds to language level all primitives expected by multithreading and the way to parallelize execution: atomic, barrier, critical and parallel at last. What wrong with the answer? It is relates to VS++, it answers how to provide multithreading without third-party library.Pentastyle
well the code posted in the question is related to c++0x's thread library, which OpenMP doesn't implement, thus my comment.Ascanius
@Ascanius - look at answer by James McNellis: "Visual C++ 2010 does not provide the C++0x thread support or atomics libraries." Which means that no way to run this code. This leads us to search some work around - either use third party (James McNellis already shows this solution), or use already on board functionality. OpenMP is provided with VC++. In both ways code should be rewritten.Pentastyle

© 2022 - 2024 — McMap. All rights reserved.