Re: linux headers and C++

Richard B. Johnson (root@chaos.analogic.com)
Thu, 1 Jul 1999 17:52:04 -0400 (EDT)


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

> I'm trying to build a kernel module in C++. This code includes some of
> the linux kernel header files, and unfortunately does not compile with
> recent versions of the kernel. The code is not my own - I have
> inherited it from someone else - but I am assured that it used to
> compile.
>
> The error I get has to do with include/linux/signal.h under the kernel
> source tree: the functions siginitset and siginitsetinv both contain
> switch statements which are invalid C++ syntax (and in fact, are
> invalid in C, but which make use of a gcc extension). Specifically,
> the last label ("case 1:") in these statements should be followed by a
> semicolon.
>

Err Lines 137 thru 190...

switch (_NSIG_WORDS) {
default:
memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
break;
case 2: set->sig[1] = -1;
case 1:
}

... seems okay to me.

case 1: falls off the end of the switch which is legal in 'C'.

To make this more clear. Observe:

switch(foo)
{
case 0:
case 1:
case 2:
default:
}

This is basically a NOP. Perfectly legal (and useless).

Your code might not compile because some "include" file, necessary
to make some macros in this header make sense, probably was not included.

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/