Re: linux headers and C++

Tom Eastep (eastep@loc1.tandem.com)
Fri, 02 Jul 1999 01:27:46 +0000


"Richard B. Johnson" wrote:
>
> 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.

Our C++ compiler gives a warning "expected a statement" but produces a
binary.

Inserting ";" after "default:" removes the warning.

-Tom

-- 
Tom Eastep
Compaq Computer Corporation
Tandem Division
tom.eastep@compaq.com

- 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/