I found this code , when I compile it , the compiler tell me "subscripted value is neither array nor pointer" . I know my platform is old . but I want know that "unsigned int bValue = {0}" is a new way to init array ?
unsigned int bValue = {0};
uBlockSize = sizeof(bValue) / sizeof(unsigned int);
for (i = 0; i < uBlockSize; i++)
bValue[i] = ui8Value << 24U |
ui8Value << 16U |
ui8Value << 8U |
ui8Value;
I want know that "unsigned int bValue = {0}" is a new way to init array ?
You declared a scalar object of the type
unsigned intThat is it is not an array declaration and hence you may not use the subscript operator with the identifier
bValue. And the compiler reports about this prohibition.However you may initialize scalar objects with expressions optionally enclosed in braces.
From the C Standard (6.7.9 Initialization)
That is the declaration itself is correct. Only it declares not an array but a scalar object.
You could declare an array for example the following way
In this case
bValueis an array with one element initialized by 0.