編譯器錯誤 C3059
'var': 'threadprivate' 符號不可使用在 'clause' 子句
子句中使用了 threadprivate 符號。
下列範例會產生 C3059:
// C3059.cpp
// compile with: /openmp
#include "omp.h"
int x, y;
#pragma omp threadprivate(x, y)
int main() {
#pragma omp parallel private(x, y) // C3059
{
x = y;
}
}
可能的解決方式:
// C3059b.cpp
// compile with: /openmp
#include "omp.h"
int x = 0, y = 0;
int main() {
#pragma omp parallel firstprivate(y) private(x)
{
x = y;
}
}