之间的区别是什么

之间的区别是什么

本文介绍了“原子”和“原子”之间的区别是什么?和“cstdatomic”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以澄清include选项之间的区别
#include< atomic> #inlucde< cstdatomic& / code>?



我猜想没有,因为它的行为相同?



我问这是因为在我的debian系统上,我只有原子,在我的kubuntu系统我有cstdatomic。




    编译器:版本4.7.2(Debian 4.7.2-4)
  • 在Kubuntu上编译:4.6.3版本(Ubuntu / Linaro 4.6.3-1ubuntu5)



解决方案

< atomic> 是C ++原子操作库。



< cstdatomic> 是C原子操作库的C ++版本。



两者都会给你例如 std :: atomic_char 只有C ++版本具有 std :: atomic< T>



通过删除 .h 扩展并在 c 前加上名称: stdatomic。 h 变为 cstdatomic 。这将把C头包括到命名空间 std 中。



还要注意 stdatomic。因此,h (和 cstdatomic )是C11, atomic 是C ++ 11可能会解释编译器支持的差异。


can someone please clarify the difference between the include options#include <atomic> and #inlucde <cstdatomic>?

I'm guessing that there is none, because its the same behaviour?

I am asking this because on my debian system I've got only the atomic and on my kubuntu system I've got the cstdatomic.

  • compiler on Debian: version 4.7.2 (Debian 4.7.2-4)

  • compiler on Kubuntu: version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

解决方案

<atomic> is the C++ atomic operations library.

<cstdatomic> is the C++ version of the C atomic operations library.

Both will give you e.g., std::atomic_char but only the C++ version has std::atomic<T>.

As a general rule, C headers should be used in C++ by removing the .h extension and prepending c to the name: stdatomic.h becomes cstdatomic. That will include the C headers into the namespace std.

Note also that stdatomic.h (and cstdatomic hence) is C11 and atomic is C++11, which might explain the difference in compiler support.

这篇关于“原子”和“原子”之间的区别是什么?和“cstdatomic”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 07:16