Re: time.h, included from videodev2.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi Ronald,

thanks for the walk-through; I understand the recursive defines problem. The redifinition errors went away using both yours and Michaels hacks. Now, however, gcc complains about a large number of parse errors in videodev2.h, the first time when reaching line 116:

/usr/include/linux/videodev2.h:116: parse error before `__s32'

and henceforth. This seems strange since the file obviously is syntaxically correct - and used e.g. when compiling xawtv, with no gcc bitching. Any hints, anyone?

-- Thomas

Ronald Bultje wrote:
Hey Thomas,

On Fri, 2003-03-28 at 10:03, Thomas Højgaard Allin wrote:

In file included from /usr/include/linux/videodev2.h:17,
                 from videograb.c:6:
/usr/include/linux/time.h:9: redefinition of `struct timespec'
/usr/include/linux/time.h:17: redefinition of `struct timeval'
make: *** [videograb] Error 1

[..]

The program include directives are as follows:
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>


The problem is as follows: $(includedir)/linux/time.h defines the
structures timespec/timeval, without actually checking for whether these
are already defined (doh until here) by looking at the POSIX defines
_STRUCT_TIMEVAL ($(includedir)/bits/time.h) or __timespec_defined
($(includedir)/time.h), all included in $(includedir)/sys/time.h, which
is included by $(includedir)/sys/types.h, which is basically included
everywhere (this is all recursive). Conclusion: they're already defined,
posix defines are used to tell us this, but $(includedir)/linux/time.h
doesn't look at them.

This means, basically, that $(includedir)/linux/time.h, is buggered.
Since it only contains structures and types that are needed either in
kernel only or are defined elsewhere (in the posix
$(includedir)/{sys/,bits/,}*.h includes), the best way to solve this (in
my opinion) is just to make $(includedir)/linux/time.h not be used, so
just define that you already included it:

/* your own includes */
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>

/* we don't want linux/time.h */
#define _LINUX_TIME_H 1
#include <linux/videodev2.h>

I use this hack myself... It's the best solution I can think of for now.
It would even be better if $(includedir)/linux/time.h gets fixed, but I
guess this will do for now.

Ronald






[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux