C17如何让我初始化原子? [英] How does C17 want me to initialize my atomics?

查看:114
本文介绍了C17如何让我初始化原子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C17标准从stdatomic.h弃用ATOMIC_VAR_INIT,这意味着它仍然支持它,但宁愿不使用它.在C17中初始化原子的正确,不建议弃用的正确方法是什么?

The C17 standard deprecates ATOMIC_VAR_INIT from stdatomic.h, meaning it still supports it but would rather it not be used. What is the correct non-deprecated way of initializing atomics in C17?

与非原子类型相同:

atomic_int foo = 42;

还有什么新东西?

推荐答案

C17可以使用通常的显式初始化来初始化原子:

C17 makes it ok to initialize atomics using the usual explicit initialization:

atomic_int n = 42;

C17确实从7.17.2.1的句子中删除了两个单词"using ATOMIC_VAR_INIT".

C17 literally just dropped the two words "using ATOMIC_VAR_INIT" from the sentence in 7.17.2.1.

这篇关于C17如何让我初始化原子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆