QQ726535609 QQ726535609 - 1 year ago 198
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?

Answer Source

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}};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download