0

I have a function that returns the current gettimeofday value as a double. The problem is the value being returned I see inside the function is not the same as the value that gets assigned outside the function.

Here is a gdb snippet -

(gdb) n
3391            START = getCurrentTime()
(gdb) s
getCurrentTime () at file1.c:583
583             gettimeofday(&curTime, NULL);
(gdb) n
584             time = (double)(1.e3*curTime.tv_sec) + (double)(1.e-3*curTime.tv_usec);
(gdb) n
587             return time;
(gdb) p time
$77 = 1392323782187.8721
(gdb) n
588     }
(gdb) n
function3 () at file2.c:3406
3406            if (0 < var2)
(gdb) p START
$78 = 187872
(gdb) p (double)START
$79 = 187872

As you can see the value of START does not match with time !

START is defined as double START

How do I find out what is causing this problem?

punekr12
  • 653
  • 2
  • 7
  • 14

0 Answers0