11-09-2013, 07:58 PM
Would the following example be compliant with rule #9.3?
Code:
int a[3][2] = {0};
Welcome to the new MISRA discussion forum, if you were previously a member of our forums you may need to reset your password.
9.3 and {0}
|
11-09-2013, 07:58 PM
Would the following example be compliant with rule #9.3?
Code: int a[3][2] = {0};
12-09-2013, 08:59 AM
Yes this is compliant.
See Exception 1: Quote:An initializer of the form { 0 } may be used to explicitly initialize all elements of an array object or sub-object.
Posted by and on behalf of the MISRA C Working Group
20-03-2015, 01:23 AM
Would the following examples be compliant with rule #9.3?
Code: char_t a[5] = { '\0' }; Code: uint16_t a[3][2] = {0u}; Code: static uint16_t glob_arr[3] = {0u}; Code: float32_t a[3][2] = {0.0f};
<t></t>
01-04-2015, 11:49 AM
Your examples are all non compliant. You may either use the { 0 } syntactic form or you can initialise all elements of the array. E.g.
Code: static uint16_t glob_arr[3] = {0u, 0u, 0u}; /* Compliant - all items initialised */
Posted by and on behalf of the MISRA C Working Group
|
« Next Oldest | Next Newest »
|