By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,785 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,785 IT Pros & Developers. It's quick & easy.

When I declare the following structure in my code

P: 62
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
Oct 31 '06 #1
Share this Question
Share on Google+
2 Replies

Banfa
Expert Mod 5K+
P: 8,997
It is an array of structures, you need braces for the array and braces for each structure so correctly it is

Expand|Select|Wrap|Line Numbers
  1. static struct rwtable{         /* reserved word table */
  2.         char *rw_name;         /* representation */
  3.         int rw_yylex;           /* yylex() value */
  4.         }rwtable[] = {{" ",0}};
  5.  
If you have more than 1 structure in the array then it becomes

Expand|Select|Wrap|Line Numbers
  1. static struct rwtable{         /* reserved word table */
  2.         char *rw_name;         /* representation */
  3.         int rw_yylex;           /* yylex() value */
  4.         }rwtable[] = {
  5.                 {" ",0},
  6.                 {"A",1}
  7.         };
  8.  
Oct 31 '06 #2

P: 62
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


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

Expand|Select|Wrap|Line Numbers
  1. static struct rwtable{         /* reserved word table */
  2.         char *rw_name;         /* representation */
  3.         int rw_yylex;           /* yylex() value */
  4.         }rwtable[] = {{" ",0}};
  5.  
If you have more than 1 structure in the array then it becomes

Expand|Select|Wrap|Line Numbers
  1. static struct rwtable{         /* reserved word table */
  2.         char *rw_name;         /* representation */
  3.         int rw_yylex;           /* yylex() value */
  4.         }rwtable[] = {
  5.                 {" ",0},
  6.                 {"A",1}
  7.         };
  8.  
Oct 31 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.