c语言定义布尔数组,C中的布尔数组初始化

C说:

(C11, 6.7.9p23) “The evaluations of the initialization list expressions are indeterminately sequenced with respect to one another and thus the order in which any side effects occur is unspecified.”

并在C99

(C99, 6.7.8p23) “The order in which any side effects occur among the initialization list expressions is unspecified.”

这就是说声明

bool condition[10] = {true,condition[5]=true};

可以有同样的行为:

bool condition[10] = {true, 1};

或作为

bool condition[10] = {true, 1, [5] = true};

condition [5] = true评估是在数组成员的0初始化之前或之后完成的。

编辑:缺陷报告#208中存在数组元素的未指定初始化顺序的情况。情况不同,因为在DR示例中,单个元素有两个初始化器。

int a [2] = { f (0), f (1), [0] = f (2) };

It was the intention of WG14 that the call f(0) might, but need not, be made when a is initialized. If the call is made, the order in which f(0) and f(2) occur is unspecified (as is the order in which f(1) occurs relative to both of these). Whether or not the call is made, the result of f(2) is used to initialize a[0].

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值