Re: Improper headers

From: Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
Date: Sun Feb 27 2000 - 10:08:34 EST


On Sun, 27 Feb 2000 10:18:11 -0500, Shourya Sarcar wrote:
> The header files in /usr/include and /usr/include/linux seem o be rather
> inconsistent. The following code spews errors.
>
> test.c
>
> #include <time.h>
> #include <linux/time.h>
>
> int main() {}
>
> gcc -Wall test.c . Lots of errors.

  In file included from foo.c:2:
  /usr/include/linux/time.h:6: redefinition of `struct timespec'
  foo.c: In function `main':
  foo.c:4: warning: control reaches end of non-void function

The last warning is because you fail to return a value.

> One bypass would be to use any 1 of the headers but a problem is the
> following case :
>
> #include <foo.h> /* This in turn includes <time.h> */
> #include <moo.h> /* This in turn includes <linux/time.h> */
>
> Any workarounds ??

Just don't include linux/time.h. It is meant for _kernel_ use, not for
_userland_. If you really want to convert timespec to jiffies (I fail to
see why that would be useful in userland), just "#define _STRUCT_TIMESPEC"
before you include linux/time.h.

Erik

-- 
Feb 27 16:07:27 linux kernel: lp0 printer error
Feb 27 16:07:28 linux kernel: lp0 on fire
  -- Linux kernel log

- 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 : Tue Feb 29 2000 - 21:00:17 EST