When I declare the following structure in my code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srikar
    New Member
    • Sep 2006
    • 62

    When I declare the following structure in my code

    Hi all

    When I declare the following structure in my code
    static struct rwtable{ /* reserved word table */
    char *rw_name; /* representation */
    int rw_yylex; /* yylex() value */
    }rwtable[] = {" ",0};

    I am getting the warning that aggregate has a partly braketted initialiser
    help me to resolve this warning.

    regards

    srikar
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It is an array of structures, you need braces for the array and braces for each structure so correctly it is

    Code:
    static struct rwtable{         /* reserved word table */
            char *rw_name;         /* representation */
            int rw_yylex;           /* yylex() value */
            }rwtable[] = {{" ",0}};
    If you have more than 1 structure in the array then it becomes

    Code:
    static struct rwtable{         /* reserved word table */
            char *rw_name;         /* representation */
            int rw_yylex;           /* yylex() value */
            }rwtable[] = {
                    {" ",0},
                    {"A",1}
            };

    Comment

    • srikar
      New Member
      • Sep 2006
      • 62

      #3
      Hai Banfa Thank you very much, I am getting no warnings
      after I make the change.
      I spent lot of time on it.
      thank u very much
      regards
      srikar


      Originally posted by Banfa
      It is an array of structures, you need braces for the array and braces for each structure so correctly it is

      Code:
      static struct rwtable{         /* reserved word table */
              char *rw_name;         /* representation */
              int rw_yylex;           /* yylex() value */
              }rwtable[] = {{" ",0}};
      If you have more than 1 structure in the array then it becomes

      Code:
      static struct rwtable{         /* reserved word table */
              char *rw_name;         /* representation */
              int rw_yylex;           /* yylex() value */
              }rwtable[] = {
                      {" ",0},
                      {"A",1}
              };

      Comment

      Working...