title: OpenMP properly declaring variables
body: <p>I'm completely new to OpenMP and parallelization, so while this problem is likely very simple, I'm not sure what's causing it or how to search for the solution. My code is:</p>
  
  <pre><code>int FindPrime(int size) {
      long long next_p = 2;
      #pragma omp parallel \
          shared(next_p,size)
      long long tid = omp_get_thread_num();
      long long tnum = omp_get_num_threads();
      for(int long long i = tid; i &lt; size; i=i+tnum) {
          long long j;
          j=next_p+1;
           while (!IsPrime(j)) {
              j++;
          }
          next_p = j;
      }
      return next_p;
  }
  </code></pre>
  
  <p>There is also a main function which calls <code>FindPrime</code>, and <code>isPrime</code> which checks whether or not a number is prime.</p>
  
  <p>When I try compiling this code with g++ and the flags <code>-fopenmp</code> and <code>-lpthread</code>, I get the result </p>
  
  <pre><code>error: 'tid' was not declared in this scope
  </code></pre>
  
  <p>pointing to the line</p>
  
  <pre><code>for(int long long i = tid; i &lt; size; i=i+tnum){
  </code></pre>
  
  <p>It's also strange to me that it only complains about <code>tid</code>, and not <code>tnum</code>, which also comes from an OpenMP function.</p>