user541686
user541686

Reputation: 210352

OpenMP error: 'X' is predetermined 'shared' for 'private'

Does anyone know why the following code

void foo(const int X)
{
    #pragma omp parallel for private(X)
    for (int i = 0; i < 100; i++)
    {  }
}

gives this error

error: 'X' is predetermined 'shared' for 'private'

and how I can really make X private to each thread?

Upvotes: 3

Views: 2321

Answers (1)

csgillespie
csgillespie

Reputation: 60452

You are getting an error because X is constant. Just remove const and everything should work.

Upvotes: 2

Related Questions