非常に単純なコードで、コンパイラが私の使用についてエラーをスローする理由がわかりませんomp atomic capture
// my_class.h
class my_class
{
my_class()
{ }
static int class_int;
static int get_next_int();
};
// my_class.cpp
int my_class::get_next_int()
{
int next_int;
#pragma omp atomic capture
next_int = class_int++;
return next_int;
}
コンパイラエラー:
my_class.cpp: In static member function 'static int
my_class::get_next_int()':
my_class.cpp:2069: error: expected end of line before 'capture'
my_class.cpp:2070: error: invalid operator for '#pragma omp atomic' before '=' token
それは何か関係があるのstatic
でしょうか?理由が想像できない...
代わりに使用すると、正常にpragma omp critical
動作します(コンパイラエラーはありません)。
PS私は #include <omp.h>
すべての.hと.cppにあります。そして-fopenmp
、いつものように、とリンクします