[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: signal.h conflicting with linux/signal.h (2.4.0)
Guennadi Liakhovetski wrote:
>
> Hi
>
> Yesterday I was writing a user-space programme, for which I thought I
> needed (well, eventually I managed without it, but still...) linux/signal.h.
> Then I found out that everything there is hidden from user-space
> programmes by the
> #ifdef __KERNEL__
> instruction. Ok, although I actually needed one of those structs (namely
> struct sigpending), I found a way around it. But, while I tried compiling
> my programme, g++ complained about a conflicting declaration of sigset_t
> in asm/signal.h, #included from linux/signal.h (so, there are some
> declarations exposed to the user space there) and /usr/include/signal.h.
> The latter one was included from some another and another and another
> C++ header... So, is it so, that user-space programmes should not #include
> linux/signal.h nor asm/signal.h (then why isn't sigset_t from asm/signal.h
> hidden by #ifdef __KERNEL__ too?) or what?
Userspace code should never directly #include <[linux|asm]/anything>.
If the userspace headers for the libraries that implement the
relevant functions need to include the kernel headers, they will.
But glibc doesn't do that; the interface between glibc and the
kernel is completely hidden from user code, which is exactly as
it should be. I think older Linux libc4/5 headers included kernel
headers, though.
There are probably exceptions to the rule above, for code that
does very Linux-centric, non-portable tasks that are not supported
by glibc.
Regards,
-- Joe
> Thanks
> Guennadi
> ___
>
> Dr. Guennadi V. Liakhovetski
> Department of Applied Mathematics
> University of Sheffield, U.K.
> email: G.Liakhovetski@sheffield.ac.uk
>
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/
> IRC Channel: irc.openprojects.net / #kernelnewbies
> Web Page: http://www.kernelnewbies.org/
-- Joe Knapka
"It was just a maddened crocodile hidden in a flower bed. It could
have happened to anyone." -- Pratchett
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
* Evolution is an "unproven theory" in the same sense that gravity is. *
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/