如何在visual studio 2010 express版上启用C++ 11编译器?
问题描述:
我正在使用tbb :: parallel_for函数使用lambdas。我收到的语法错误与下面的代码:如何在visual studio 2010 express版上启用C++ 11编译器?
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 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 ==========
我认为这是与编译器的问题。我如何获得visual studio 2010快速版的C++ 11编译器。请建议。
答
要获得C++ 11功能,您应该使用最新版本Visual Studio 2012。
的Visual C++ 2010中实现在C++ 0x中的核心语言规范,这是前体对C++ 11的许多功能,并在Visual Studio中的Visual C++ 2012上扩展到包括许多C++ 11功能。
答
Visual C++ 2010 Express确实包含C++ 11功能,但不是全部。以下列出了它支持的功能(以及VC++ 2012): http://msdn.microsoft.com/en-ca/library/vstudio/hh567368.aspx
什么是第16行和第17行? – 2013-04-07 18:11:21
“tbb :: parallel_for”是第16行,“for(Vertex * vit = r.begin(); vit!= r.end(); ++ vit)”是第17行 – Hello 2013-04-07 18:30:25
,所以我将无法因为我在Windows 7上使用C++ 11,并且只能使用Visual Studio 2010?顺便说一句...我不想用MinGW G ++的Eclipse,因为我觉得它很难看...... :( – ha9u63ar 2014-11-01 15:44:55