Thread (1 message) 1 message, 1 author, 2020-01-30

Re: Including both linux/time.h and linux/input.h causes failure

From: Elichai Turkel <hidden>
Date: 2020-01-30 14:12:31

Mostly I need the uid_t type for syscalls(getuid/setuid)
Which is defined in sys/types.h but that header also includes time
related stuff.

For context I'm writing a libc equivilant library (in rust).

Thanks,
Elichai.

On Wed, Jan 29, 2020 at 7:16 PM Carlos O'Donell [off-list ref] wrote:
On 1/29/20 10:14 AM, Elichai Turkel wrote:
quoted
Hi,
The following header: <wrapper.h>:
#include <linux/input.h>
#include <linux/time.h>
Will cause the compiler to fail because of redefinition of a lot of
time related structs, that are declared once in `linux/time.h` and
then again via `bits/types/struct_timeval.h` which is included through
`linux/input.h > sys/time.h -> bits/types/struct_timeval.h`
This is another header-coordination issue between the kernel and libc.

In this case it's linux/time.h vs. sys/time.h.

"Synchronizing Headers"
https://sourceware.org/glibc/wiki/Synchronizing_Headers
- Just added your case.

It's not immediate clear to me if the UAPI header is clean enough to
use directly in glibc or not, and that's often the simplest way to fix
things.

When you can't just use the kernel header definitions then you have
to work through the conflict and decide if you want to allow both headers
to be potentially included and in which orders to support it.

Why do you need both headers included?

--
Cheers,
Carlos.

-- 
PGP: 5607C93B5F86650C
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help