我在尝试编译C程序时遇到此错误:
omptest.c: In function ‘int ack(int, int)’:
omptest.c:13:23: error: invalid form of ‘#pragma omp atomic’ before ‘;’ token
ans = ack(m-1,1);}
^
omptest.c:18:31: error: invalid form of ‘#pragma omp atomic’ before ‘;’ token
ans = ack(m-1, ack(m,n-1));
我不知道如何发生此错误。这是我的计划:
#include <stdio.h>
#include <omp.h>
int ack(int m, int n)
{
int ans;
if (m == 0)
ans = n+1;
else if (n == 0)
#pragma omp task
{
#pragma omp atomic
ans = ack(m-1,1);}
else
#pragma omp task
{
#pragma omp atomic
ans = ack(m-1, ack(m,n-1));}
#pragma omp taskwait
return (ans);
}
int main(int argc, char const *argv[])
{
int i,j;
for (i=1; i<6; i++)
for (j=0;j<6; j++)
printf("ackerman (%d,%d) is: %d\n",i,j, ack(i,j));
return 0;
}