On Aug 18, 7:33*pm, Julián Rodríguez Bajo <jrodrig...@amper.es> wrote:
> El 18/08/2010 13:30, thomas escribió:
>
>
>
> > Hi, I need your help.
>
> > ----------
> > struct SvrList{
> > * * *unsigned int uNum;
> > * * *GameSvr *svr[0]; * * * * * *//line A
> > };
> > ---------
>
> > Once I declared a struct like this to store server list info.
> > It's supposed to be used like this.
>
> > ----------
> > SvrList* pList = (SvrList*)malloc(sizeof(
> > SvrList) + svrNum*sizeof(GameSvr));
> > pList->uNum, pList->svr[0], pList->svr[1].... blabla..
> > ---------
>
> > The vs2005 compiler gives me the "nonstandard extension used : zero-
> > sized array in struct/union" warning though.
>
> > I may keep my eye closed to the warning since everything looks fine.
> > But I don't know whether anything bad may happen to me some day due to
> > running environment changes(porting to different platforms, or any
> > other conditions).
>
> > One work-around way is to declare a one-sized array as struct member,
> > but I didn't see any substantial changes except no warning in this
> > case.
>
> > Any body give some suggestions?
>
> You can change to
>
> struct SvrList{
> * * * unsigned int uNum;
> * * * GameSvr **svr; * * * * * *//line A
>
> };
>
> and still use array indexes.
Thanks, that works.
But I will call "new" two times: one to allocate memory for struct
SvrList, one for "*svr".
I really want to know whether there's any side effect if I use zero-
sized member.
|