NO

Author Topic: Version 9.00.9 "i is not unsigned type" error #2918.  (Read 2845 times)

Abraham

  • Guest
Version 9.00.9 "i is not unsigned type" error #2918.
« on: October 07, 2018, 09:42:06 PM »
Code: [Select]
#include <stdio.h>
#define ITERATIONS 100000000
int main(void)
{
    double pi = 0;
    long i;

    /* pi/4 = 1/1 - 1/3 + 1/5 - 1/7 + ... */
    #pragma omp parallel for reduction(+:pi)
    for (i = 0; i < ITERATIONS; i++)
    {
        pi += 1.0 / (i * 4.0 + 1.0);
        pi -= 1.0 / (i * 4.0 + 3.0);
    }
    pi = pi * 4.0;
    printf("pi = %f\n", pi);

    return 0;
}

error #2918: [omp] Unrecognized or unsupported form of 'for' construct.

The only way to solve this issue is to change i to size_t.

Edit:
I made a mistake. The iterater only needs to be unsigned type. It failed with signed types.

Edit:
Changed the Subject, not sure if it would change the title of the thread.
« Last Edit: October 07, 2018, 09:47:53 PM by Abraham »