[LC++]gettimeofday and C++

Jack Lloyd lloyd at acm.jhu.edu
Sun Nov 11 12:22:21 UTC 2001


> gettimeofday() is a Unix and not an ANSI-C function, so there isn't a Std-C++
> ctime header file and it is not in std namespace.
>
> In fact, it is not even POSIX -- the POSIX function time() is in time.h, the
> BSD gettimeofday() is in sys/time.h in Linux/BSD systems.

For high resolution clocks, consider the POSIX.1b timer functions, like
(IIRC) clock_gettime. Higher resolution (theoretically) than gettimeofday,
and (theoretically) more portable. If you're interested, I think I have a
draft copy of POSIX1-2000 somewhere which documents the whole thing in
excruciating (and it truly is that) detail that I can put online. -J




More information about the tuxCPProgramming mailing list