请考虑以下代码段:
#include <map>
class A {
static std::map<int,int> theMap;
#pragma omp threadprivate(theMap)
};
std::map<int,int> A::theMap;
Run Code Online (Sandbox Code Playgroud)
使用OpenMP进行编译失败,并显示以下错误消息:
$ g++ -fopenmp -c main.cpp
main.cpp:5:34: error: ‘threadprivate’ ‘A::theMap’ has incomplete type
Run Code Online (Sandbox Code Playgroud)
我不明白这一点.我可以编译没有#pragma指令,它应该意味着std::map是不完整的.如果Map是基本类型(double,int ...),我也可以编译.
如何制作全局静态std::map threadprivate?