aa**********@gmail.com wrote:
I'm trying to use the timersub macro on Ubuntu Linux. When I compile I
get the error:
<file>.c:<line #>: warning: implicit declaration of function
'timersub'
Where <fileis the file name and <line #is the line number. I take
that to mean I that the timersub macro hasn't been #included. My code
looks about like this:
#include <time.h>
#include <sys/time.h>
struct timeval *time_start, *time_end, *time_diff;
gettimeofday(time_start);
// some stuff runs
gettimeofday(time_end);
timersub(time_start, time_end, time_diff);
What am I doing wrong?
-Aaron
timersub is defined in time.h
# define timersub(a, b, result) \
do {
\
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec;
\
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec;
\
if ((result)->tv_usec < 0) {
\
--(result)->tv_sec;
\
(result)->tv_usec += 1000000;
\
}
\
} while (0)
BUT
this macro will be defined ONLY if the preprocessor symbol
__USE_BSD
is defined.
Probably you have to convince gcc to define that symbol.
Read the documentation for that.
In ANY case if the definition isn't seen the link will not work since
timersub is a compiler macro and will be absent from the libraries
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32