Compiler Error C3038
'var' : variable in 'private' clause cannot be a reduction variable in enclosing context
Variables that appear in the reduction clause of a parallel directive cannot be specified in a private clause on a work-sharing directive that binds to the parallel construct.
The following sample generates C3038:
// C3038.cpp
// compile with: /openmp /c
int g_i, g_i2;
int main() {
int i;
#pragma omp parallel reduction(+: g_i)
{
#pragma omp for private(g_i) // C3038
// try the following line instead
// #pragma omp for private(g_i2)
for (i = 0; i < 10; ++i)
g_i += i;
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for