Edit

Share via


Compiler Error C3048

Expression following '#pragma omp atomic' has improper form

An atomic directive was incorrectly specified.

The following sample generates C3048:

// C3048.cpp
// compile with: /openmp vcomps.lib
#include "omp.h"
#include <stdio.h>

int main() {
   int a[10];
   omp_set_num_threads(4);
   #pragma omp parallel
   {
      #pragma omp atomic
      a[0] = 1;   // C3048
      // try the following line instead
      // a[0] += 1;
   }
}