非常簡單的代碼,不明白爲什麼編譯器會引發錯誤對我使用的omp atomic capture
C++ omp原子捕獲 - 語法?
// 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我在所有的.h和.cpp #include <omp.h>
。和我一起-fopenmp
鏈接,像往常一樣
你使用什麼編譯器? – 2012-08-07 16:37:27
g ++(Debian 4.4.5-8)4.4.5 – cmo 2012-08-07 19:37:51