Windows上的MinGW GCC 4.8.0不支持原子功能

时间:2014-02-06 13:59:03

标签: c++ gcc c++11 g++ atomic

#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的错误吗?我怎样才能解决这个奇怪的问题...

0 个答案:

没有答案