android 多重数组,android – 缺少多维数组的大括号

当我在Visual Studio中为Android共享库构建项目时,我收到了一条警告消息.

warning : suggest braces around initialization of subobject

[-Wmissing-braces]

此消息指示仅使用一对大括号的数组初始化语句.

int myArray [ROW] [COL] = {1,2,3,4,5,6,…,451,452,453};

我不能用两对书写的原因是将来有可能改变ROW和COL的大小.

它运行正常,但我不确定是否可以这样离开项目,因为在为仅Windows应用程序编写代码时,我从未见过这样的警告消息.

我是否必须认真对待这件事?

解决方法:

你所拥有的是通过大括号缩写称为聚合初始化,你完全没问题,代码符合标准.

If the aggregate initialization uses the form with the equal sign (T a

= {args..}), (until C++14) the braces around the nested initializer lists may be elided (omitted), in which case as many initializer

clauses as necessary are used to initialize every member or element of

the corresponding subaggregate, and the subsequent initializer clauses

are used to initialize the following members of the object. However,

if the object has a sub-aggregate without any members (an empty

struct, or a struct holding only static members), brace elision is not

allowed, and an empty nested list {} must be used.

查看更多详情here和here.

标签:c-2,arrays,android,warnings,braces

来源: https://codeday.me/bug/20190609/1203114.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值