I don't know how to make a struct or object as threadprivate, what I'm doing generates a error:
struct point2d{
int x;
int y;
point2d(){
x = 0;
y = 0;
}
//copy constructor
point2d(point2d& p){
x = p.x;
y = p.y;
}
};
I declare a static structure and try to make them threadprivate
static point2d myPoint;
#pragma omp threadprivate(myPoint)
It generates an error:
error C3057: 'myPoint' : dynamic initialization of 'threadprivate' symbols is not currently supported
Does it means that current openmp compiler doesn't support this to make a struct threadprivate? Or what I'm doing is wrong.
Is there any alternate way to pass a struct or object?
Here's rest part of my codes:
void myfunc(){
printf("myPoint at %p
",&myPoint);
}
void main(){
#pragma omp parallel
{
printf("myPoint at %p
",&myPoint);
myfunc();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…