It's an older C way of giving types to the function arguments. It has
since been changed so you can do it the old way, or the way most of us
are used to doing it (the term most is open to interpretation here). It
is equivalent to saying:
int timeval_subtract (timeval *result, timeval *x, timeval *y)
{
// do stuff
}
-Austin
Grant Kelly wrote:
I came across this code which does something I've never seen before.
Could someone explain what the variable declaration between the
function header and the function body do? Or at least point me in a
direction to find out for myself. Again, I know what the code does,
but I don't know what the line marked with <==== does.
Thanks,
Grant
int timeval_subtract (result, x, y)
struct timeval *result, *x, *y; <==== What does this do???
{
/* Perform the carry for the later subtraction by updating y. */
if (x->tv_usec < y->tv_usec) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
y->tv_usec -= 1000000 * nsec;
y->tv_sec += nsec;
}
if (x->tv_usec - y->tv_usec > 1000000) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000;
y->tv_usec += 1000000 * nsec;
y->tv_sec -= nsec;
}
/* Compute the time remaining to wait.
tv_usec is certainly positive. */
result->tv_sec = x->tv_sec - y->tv_sec;
result->tv_usec = x->tv_usec - y->tv_usec;
/* Return 1 if result is negative. */
return x->tv_sec < y->tv_sec;
}
------------------------------------------------------------------------
_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug
--
Austin Stanhope www.cse.unr.edu/~stanhope
Robotics Research www.cse.unr.edu/~society
Computer Science and Engineering www.cse.unr.edu
University of Nevada, Reno www.unr.edu
Abuse it and you'll loose it. I WILL Procmail you.
Think before you click that forward button.
_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug