Re: linux headers and C++

Richard B. Johnson (root@chaos.analogic.com)
Thu, 1 Jul 1999 20:32:00 -0400 (EDT)


On Thu, 1 Jul 1999, Ronnie G Misra wrote:

> root@chaos.analogic.com wrote:
> > To make this more clear. Observe:
> >
> > switch(foo)
> > {
> > case 0:
> > case 1:
> > case 2:
> > default:
> > }
> >
> > This is basically a NOP. Perfectly legal (and useless).
>
> Try compiling that code with "gcc -pedantic" and you will find that
> this is not legal ANSI C. It is legal in gcc because it is a gcc
> extension.
>
> Try compiling with g++, and you will get a parse error.
>
> Ronnie Misra rgmisra@mit.edu
> 3 Ames Street, Box 152
> Cambridge, MA 02142
> (617) 225-6365

Yes. You are correct. I tried it with several 'non-gcc, non-unix'
compilers and they seem to require that a switch include at least
one statement within it. A ';' will suffice. I don't know if this
is really ANSI, someone else will probably comment.

FYI lint finds nothing wrong with it. Further {} seems to be okay
as well as {;}, so I can't guess what rule is being violated.

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/