Compiler Error C3039
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3039.
var' : index variable in OpenMP 'for' statement cannot be a reduction variable
An index variable is implicitly private, so the variable cannot be used in a reduction clause in the enclosing parallel directive.
The following sample generates C3039:
// C3039.cpp
// compile with: /openmp /c
int g_i;
int main() {
int i;
#pragma omp parallel reduction(+: i)
{
#pragma omp for
for (i = 0; i < 10; ++i) // C3039
g_i += i;
}
}
Show: