[Q] proper definition of "struct timeval" ?

Yui-wah LEE (clement@ux3.sp.cs.cmu.edu)
Thu, 6 Mar 1997 17:15:38 -0500 (EST)


Hi,

What is the proper type of "struct timeval" ? Seems that linux's
definition is different to other's ...

--- other
+++ linux
struct timeval {
- long tv_sec; /* seconds */
+ int tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
+ int tv_usec; /* and microseconds */
};

"other" means ANSI, ultrix, mach etc, "linux" means linux 2.0.18, 2.0.27
etc (linux's defined in /usr/src/linux/include/linux/time.h, symlinked
_to_ by /usr/include/linux/time.h )

Why is that so ? While it doesnot break my software (yet) since both long
and int are 32-bit on my machine, gcc does complaint about the type
difference. And seems that we have no guarantee that long and int
will always be the same.

Thanks !

-- LEE, Yui-wah (Clement),