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

Re: Re[2]: Intent to Rewrite: pwgen

On Thu, May 31, 2001 at 08:42:28PM +0200, Dominik 'IronHand' Dalek wrote:
> > Using struct timespec is just wrong.  The problem
> > seems to be a missing #include of sys/types.h.  It doesn't seem to be
> > necessary on my Debian/woody compile environment, but it is
> > technically necessary.
> Why timespec is wrong? It's a substitute (it's said like that in time.h)
> according to POSIX.4 (AFAIR, because I'm using Wimdows right now and
> can't check for sure).

It's wrong because gettimeofday() doesn't fill in a struct timespec;
it fills in a struct timeval.  You basically made random
(non-type-safe) changes to the program until it compiled; luckily for
you the layour of struct timeval and struct timespec are similar.

If you want to use the POSIX.4 interface, you need to use
clock_gettime().  However, the reality is that gettimeofday() is more
portable than clock_gettime(), simply because not all OS's have
implemented all of the POSIX.4 interfaces, whereas BSD and System V
derived systems (which basically covers everybody) has gettimeofday().

The real issue was a missing #include of <sys/time.h>.  

							- Ted

Reply to: