Compiler Error C3038
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error C3038

Error Message

'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;
© 2016 Microsoft