[previous] 0693 [next] Struct initializer is missing the optional {.
Arrays, structures, unions and bit-fields REFERENCE - ISO:C90-6.5.7 Initialization - Semantics

The initializer for a nested structure has not been enclosed in braces. Braces are optional in this context but nevertheless helpful.

For example:


/*PRQA S 750,1256,1278,2017,2213,3120,3132,3211,3408,3629 ++*/

    union UNA
    {
        unsigned long ul;
        float ft;
    };

    struct BASE1
    {
        int a;
        int b;
    };

    struct BASE1 x1[2] = { 1, 2, 3, 4 };          /* Message 0693 */
    struct BASE1 y1[2] = { {1, 2}, {3, 4} };      /* OK */


    struct BASE2
    {
        int a[2];
        int b;
    };

    struct BASE2 x2 = {1, 2, 3};                  /* Message 0694 */
    struct BASE2 y2 = {{1, 2}, 3};                /* OK */


    struct BASE3
    {
        union UNA a;
        int b;
    };

    struct BASE3 x3 = {1UL, 2};                   /* OK */
    struct BASE3 y3 = {{1UL}, 2};                 /* OK */


    int x4[2][2] = { 1, 2, 3, 4 };                /* Message 0694 */
    int y4[2][2] = { {1, 2}, {3, 4} };            /* OK */


See also:

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