MISRA.DECL.ARRAY_SIZEDeclaration of array with unknown size. MISRA C 2012 Rule 8.11: When an array with external linkage is declared, its size should be explicitly specifiedCategory: Advisory Analysis: Decidable, Single Translation Unit Applies to: C90, C99 AmplificationThis rule applies to non-defining declarations only. It is possible to define an array and specify its size implicitly by means of initialization. RationaleAlthough it is possible to declare an array with incomplete type and access its elements, it is safer to do so when the size of the array may be explicitly determined. Providing size information for each declaration permits them to be checked for consistency. It may also permit a static checker to perform some array bounds analysis without needing to analyse more than one translation unit. Exampleextern int32_t array1[ 10 ]; /* Compliant */ extern int32_t array2[ ]; /* Non-compliant */ MISRA-C 2004 Rule 8.12 (required): When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialisation.Exampleint array1[ 10 ]; /* Compliant */ extern int array2[ ]; /* Not compliant */ int array2[ ] = { 0, 10, 15 }; /* Compliant */ Although it is possible to declare an array of incomplete type and access its elements, it is safer to do so when the size of the array may be explicitly determined. MISRA-C++ 2008 Rule 3-1-3 (required): When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.[Undefined 5.7(5, 6)] RationaleAlthough it is possible to declare an array of incomplete type and access its elements, it is safer to do so when the size of the array can be explicitly determined. Exampleint32_t array1[ 10 ]; // Compliant extern int32_t array2[ ]; // Non-compliant int32_t array3[ ] = { 0, 10, 15 }; // Compliant extern int32_t array4[ 42 ]; // Compliant |