#include <atomic>
struct SomeType
{
int a;
int b;
int c;
int d;
};
int main()
{
SomeType s1 = {1, 2, 3, 4};
std::atomic<SomeType> s2(s1);
SomeType s3 = s2.load();
return 0;
}
代码未使用gcc version 4.8.0 (rev2, Built by MinGW-builds project)
与gcc -std=c++11 t.cpp
进行关联。错误消息是:
ccGPZTVk.o:t.cpp(.text$_ZNKSt6atomicI8SomeTypeE4loadESt12memory_order[__ZNKSt6atomicI8SomeTypeE4loadESt12memory_order]+0x21): undefined reference to `__atomic_load_16'
collect2.exe: error: ld returned 1 exit status
根据C ++ 11标准,像SomeType
这样简单易复制的类型应该绝对适合std :: atomic ......而MSVC cl /EHsc t.cpp
就像魅力一样。这是GCC的错误吗?我怎样才能解决这个奇怪的问题...