共用方式為


編譯器錯誤 C3030

'var': 'reduction' 子句/指示詞中的變數不能有參考類型

您只可以將實值參數傳遞給特定子句 (例如 reduction 子句)。

下列範例會產生 C3030:

// C3030.cpp
// compile with: /openmp /link vcomps.lib
#include "omp.h"

void test(int &r) {
   #pragma omp parallel reduction(+ : r)   // C3030
      ;
}

void test2(int r) {
   #pragma omp parallel reduction(+ : r)   // OK
      ;
}

int main(int argc, char** argv) {
   int& r = *((int*)argv);
   int s = *((int*)argv);

   #pragma omp parallel reduction(+ : r)   // C3030
      ;

   #pragma omp parallel reduction(+ : s)   // OK
      ;
}