On Mon, Dec 02, 2002 at 10:30:49AM -0500, Jason House wrote:
> Well, I just tried to build the latest io_stat and found that it didn't
> compile... I looked at the code and it was fine... but for whatever
> reason, visual studio doesn't like the "default:" followed by "}" with
> nothing in between.
Perhaps it doesn't like it because ANSI X3.159-1989, "American National
Standard for Information Systems -- Programming Language -- C", and
presumably the ISO standard, say, in section 3.6.1 "Labeled Statements":
Syntax
{labeled-statement}:
{identifier} : {statement}
case {constant-expression} : {statement}
default : {statement}
and nowhere, at least in a quick look, allows {statement} to be empty.
I.e., the oddity isn't that it dislikes it, as it's not valid C; the
oddity that GCC *doesn't* dislike it - it's either a deliberate GCC
extension (although the titles of extensions in the online 2.95.3
manual:
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC61
don't show anything that *immediately* suggests that as an extension) or
a consequence of the way GCC's parser was written.
> I simply added "break;" and it compiles fine now.
Checked in.
> Index: io_stat.c
> ===================================================================
> RCS file: /cvsroot/ethereal/gtk/io_stat.c,v
> retrieving revision 1.8
> diff -r1.8 io_stat.c
> 430a431
> > break;
> 458a460
> > break;
> 461a464
> > break;
> 464a468
> > break;
You might want to send patches as "diff -c" or "diff -u" patches in the
future - that one happened to apply because the current version of
"io_stat.c" is the one against which you diffed your version, but
context or unified diffs are more robust in the face of others changing
the file you're patching.