lkml.org 
[lkml]   [1999]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: linux headers and C++
"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/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.045 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site