架构的未定义符号x86_64:
“__atomic_store”,引自:
_主要在main.o
我创建了一些测试代码来复制这个
#include <iostream>#include <atomic>using namespace std;class Vec { public: int x,y,z; Vec() { x = y = z = 0; }};std::atomic<Vec> x;int main(){ Vec a; x = a; cin.get(); return 0;}
当然这个例子没有什么意义,但是我能想出的最短.它运行在VS2012,但不是在xcode(给我上面显示的链接器错误).
发生什么了?我在这里滥用std :: atomic吗?我正在研究的图书馆是多线程的,用于音频处理.所以如果我没有以正确的方式使用std :: atomic,它并不是真的显示,因为性能非常好,我没有任何线程问题.还是xcode可能缺少什么?
更新:
我已经检查了andrey的答案,因为它有最多的信息,虽然所有3个答案是有用的.我不是这个专家(显然),但似乎VS2012超出了C11中应该实现的内容.
那么怎么从这里走?我看到几个选项.
>不要为这个类使用atomic.在我特定的情况下,这将非常困难,因为我的向量类遍及代码.锁定和解锁互斥可能会减慢很多事情.
>自己实现原子的功能.对我来说看起来很复杂我会把它保存为最后一个选项.
>看看是否可以用boost :: atomic完成某些事情.这似乎乍一看.我必须做更多的测试.
The standard library provIDes full specializations of the std::atomic
template for the following types:1) One specialization for the type bool and its typedef
2)
Specializations and typedefs for integral types
3) std::atomic
for all pointer types
Boost.Atomic怎么样如Boost.Atomic limitations所述:
总结Using non-POD-classes as template parameter to atomic results in undefined behavior.
以上是内存溢出为你收集整理的std ::原子与自定义类(C 11)全部内容,希望文章能够帮你解决std ::原子与自定义类(C 11)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)