Diagnostic 29: expected an expression

Cause:
There are many possible reasons for this diagnostic message being emitted by the Intel C++ Compiler. One is from the lambda usage in the code and the option /Qstd=c++0x (-std=c++0x for Linux* and Mac OS* X) is not specified in the compiler options.

Example:

t.cpp 

#include <stdio.h>
#include "tbb/blocked_range.h"
#include "tbb/parallel_for.h"
using namespace tbb;

int total = 0;
int main(int argc, char* argv[])
{
	int mNum = 50; 
	parallel_for( blocked_range<size_t>(0, mNum, 1), [](const blocked_range<size_t> &r) { 
		for (size_t i = r.begin(); i != r.end(); ++i) { 
			total += i;
		}
	} );

	printf("total=%drn", total);
}
Output without /Qstd=c++0x:

C:\test>icl /O2 t.cpp
Intel® C++ Compiler XE for applications running on IA-32, Version 12.0.0.104 Build 20101006
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

t.cpp
t.cpp(10): error: expected an expression
        parallel_for( blocked_range<size_t>(0, mNum, 1), [](const blocked_range<size_t> &r) {
                                                         ^

t.cpp(14): warning #12: parsing restarts here after previous syntax error
        } );
          ^

compilation aborted for t.cpp (code 2)

C:\test>


Output with /Qstd=c++0x:

C:\test>icl /O2 /Qstd=c++0x t.cpp
Intel® C++ Compiler XE for applications running on IA-32, Version 12.0.0.104 Build 20101006
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

t.cpp
Microsoft ® Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:t.exe
t.obj

C:\test>


Resolution:
On Windows the /Qstd=c++0x is on by default when using the Intel C++ Compiler with Visual Studio 2010*. But it is not on when with Visual Studio 2005* or 2008*.

So the resolution is to add the compiler option /Qstd=c++0x to the compiler option list on Windows or -std=c++0x on Linux* or Mac OS* X.
For more complete information about compiler optimizations, see our Optimization Notice.