QQ726535609 QQ726535609 - 3 months ago 12
Objective-C Question

Excess elements in scalar initializer in byte create in iOS

In my project, I create a byte:

Byte bytes = {0x7E, 0x7F};

But there comes a warning:

Excess elements in scalar initializer

What this mean? does it effect me?


You are trying to create single dimensional array where you are not declaring size of it there's no memory set aside for an array so that's why the compiler is generating a warning which may cause an runtime error ahead.

Set array size:

// single dimen
Byte bytes[2] = {0x7E, 0x7F};

// double dimen
Byte bytes[1][2] = {{0x7E, 0x7F}, {0x7E, 0x7F}};