Compiler Error C3048
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at 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;
}
}
Show: