Re: [PATCH] C++ breaks on linux/ioport.h

From: Guest section DW (dwguest@win.tue.nl)
Date: Thu Apr 27 2000 - 10:41:25 EST


On Thu, Apr 27, 2000 at 10:48:44AM -0400, Paul Barton-Davis wrote:

> >From: Jes Sorensen <Jes.Sorensen@cern.ch>
>
> >Thats pretty irrelevant, you are not supposed to include the kernel
> >headers in C++ programs.

Indeed.

> I find this approach pretty worrying. Its *often* necessary to include
> such files in user-space programs that use ioctl to control various
> hardware resourcs (e.g. linux/rtc.h).

As has been reiterated dozens of times already on this list,
every program that includes <linux/foo.h> is broken or will break
sooner or later, especially if one compiles them with /usr/include/linux
pointing at a random kernel source, instead of a carefully selected
collection of headers that works well with the current libc headers.

> If the suggestion is that *no* true kernel header should ever be
> included, but that glibc should come with its own versions of them all:
> how can this cover h/w-specific resource like the RTC etc. ?

You copy linux/rtc.h to your own private file linux-rtc.h, remove the
junk you are not interested in, and have a set of sources that compiles
not only today but also tomorrow, when linux/rtc.h has a different content.
Moreover, the binary obtained by compiling it tomorrow will have the same
behaviour as the binary obtained today. No sudden obscure crashes of your
application because some structure element is now declared unsigned.

And if you ever need the very latest ioctl that does not occur yet
in today's linux/rtc.h, well - then you make a new copy of linux/rtc.h.

Always keep your program source and your kernel source separate
and independent.

Andries

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



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:13 EST