[ovs-dev] [PATCH] ofp-util: compile group stats with visual studio
Ben Pfaff
blp at nicira.com
Thu Apr 24 22:45:08 UTC 2014
On Thu, Apr 24, 2014 at 03:41:52PM -0700, Gurucharan Shetty wrote:
> On Thu, Apr 24, 2014 at 2:48 PM, Andy Zhou <azhou at nicira.com> wrote:
> > Visual studio does not support 0 size array within a struct,
> > but supports flexible array. For example, char p[0] is not supported,
> > but char p[] is O.K. GCC supports both.
> >
> > Flexible array can not directly replace a zero sized array.
> > http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html lists the
> > differences.
> >
> > Commits 644cfd84772eb7d8 and 6fdaa45a6f6c9 make use of 0 size array.
> > Convert them to flexible array so that visual studio can compile them
> > as well.
> >
> > Reported-by: Gurucharan Shetty <gshetty at nicira.com>
> > Signed-off-by: Andy Zhou <azhou at nicira.com>
>
> Eitan pointed out off-list that Zero sized arrays are supported on
> visual studio as an extension.
>
> In this particular case, zero sized array was indirectly included in
> the middle of the structure and that is not supported.
>
> So the fix is still needed, but the commit message could do with a change.
Sometimes these trailing zero-length or flexible array members don't
actually add any value (because it's easy to just use ofpbuf_push() or
ofpbuf_pull() to get past the header). Sometimes the code is even
easier to read without them. You might want to check whether deleting
them (probably adding a comment saying what follows) and then updating
the previous users is a good solution.
More information about the dev
mailing list