Reputation: 1155
1 int result = 0;
2 int b = 0;
3 #pragma omp for reduction(+:result) private(b)
4 for(int i = 0; i < size; i++) {
5 ifile >> b;
6 if(b== 100)
7 result++;
8 }
Why do I get this error?
(3) error C3037: 'result' : variable in 'reduction' clause must be shared in enclosing context
I tried googling btw... all the examples look like this. I am also coding this in visual studios 2012 if that matters. I hate asking a question like this, but it is blocking me from continuing.
Fixed: add parallel
#pragma omp parallel for private(buffer) reduction(+:result)
Upvotes: 2
Views: 1911
Reputation: 41110
You're missing the "parallel" tag from the reduction clause:
#pragma omp for reduction(+:result) private(b)
should be
#pragma omp parallel for reduction(+:result) private(b)
Upvotes: 3