共用方式為


編譯器錯誤 C3037

'var': 'reduction' 子句中的變數在封入內容中必須為共用

reduction 子句中指定的變數,對內容中的每個執行緒而言可能都不是私用。

下列範例會產生 C3037:

// C3037.cpp
// compile with: /openmp /c
int g_i;

int main() {
   int i;

   #pragma omp parallel private(g_i)
   // try the following line instead
   // #pragma omp parallel
   {
      #pragma omp for reduction(+:g_i)   // C3037
      for (i = 0 ; i < 10 ; ++i) {
         g_i += i;
      }
   }
}