[previous] 0351 [next] Using an initializer when defining an automatic object of struct, union or array type.
K+R compatibility REFERENCE - ISO:C90-6.5.7 Initialization

A local array, structure or union with automatic storage duration is being initialised. This was not permitted in early versions of the C language.

Be aware that message 0351 is only generated when the "-k+r a" option is enabled. Messages 0351 and 3604 are functionally equivalent. When the "-k+r a" option is enabled, message 3604 is no longer generated.

For example:


/*PRQA S 750,759,2017,2211,2213,2216,3120,3122,3132,3205,3223,3408,3625,3674 ++*/
/*****************************
 * OPTIONS: -k+r a
 ****************************/

struct ST {int x; int y;};
union  UN {unsigned int ui;unsigned char uc[4];};

extern void foo(void)
{
   static char a[] = "123456";          /*              */

   char c1[] = "abcdefg";               /* Message 0351 */
   char c2[] = "abcdefg";               /* Message 0351 */

   int  n1[] = { 1, 2, 3, 4 };          /* Message 0351 */
   int  n2[] = { 1, 2, 3, 4 };          /* Message 0351 */

   struct ST stx = { 10, 12 };          /* Message 0351 */
   struct ST sty = { 10, 12 };          /* Message 0351 */

   union  UN unx = { 2 };               /* Message 0351 */
   union  UN uny = { 2 };               /* Message 0351 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents