How to enable C++11 compiler on visual studio 2010 express edition?
Asked Answered
M

2

6

I am using tbb::parallel_for function which make use of lambdas. I am getting syntax errors with the following code:

void parallel_relax( Class object, std::vector<Vertex *> verList ) {
    tbb::parallel_for (blocked_range<int>(0, verList.size()), [=](const blocked_range<Vertex *>& r) {
        for(Vertex *vit = r.begin(); vit != r.end(); ++vit) {
            Vertex *v = vit;
            object.function(v);
        }
    });
}

Syntax Errors:

syntax error : '['
1>main.cpp(16): error C2143: syntax error : missing ')' before '{'
1>main.cpp(16): error C2143: syntax error : missing ';' before '{'
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.begin' must have class/struct/union
1>          type is ''unknown-type''
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.end' must have class/struct/union
1>          type is ''unknown-type''
1>main.cpp(20): error C2059: syntax error : ')'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I think this is the problem with the compiler. How do i get c++11 compiler for visual studio 2010 express edition. Please suggest.

Marvel answered 7/4, 2013 at 18:7 Comment(3)
What are lines 16 and 17?Yalu
"tbb::parallel_for" is line 16 and "for(Vertex *vit = r.begin(); vit != r.end(); ++vit)" is line 17Marvel
so I won't be able to use C++11 because I m on Windows 7 and I can only use Visual Studio 2010? BTW...I don't want to use Eclipse with MinGW G++ cause I find it ugly... :(Vermiculation
K
4

Visual C++ 2010 Express does contain C++11 features, but not all of them. Here is a list of what features it supports (as well as VC++ 2012): http://msdn.microsoft.com/en-ca/library/vstudio/hh567368.aspx

Knot answered 7/4, 2013 at 19:3 Comment(3)
How to enable C++11 features? If it is enabled by default, then why is it giving syntax errors?Marvel
As I said above, not all of them. The list is a little deceiving upon first glance, but further down you can see that support for lambdas in VC10 is only partial, which is why you're getting the syntax error.Knot
This link seems to list only VS2012,13,15Litigant
B
3

To get C++11 features you should use the latest version, Visual Studio 2012.

From C++11 Features (Modern C++):

Visual C++ 2010 implemented many features in the C++0x core language specification, which was the precursor to C++11, and Visual C++ in Visual Studio 2012 expands on that to include many C++11 features.

Billye answered 7/4, 2013 at 18:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.