On Sat, 22 Jul 2006 23:30:13 PDT, heavenscape said:

Not strictly a gtk question, but a general C programming question.
What the heck, I'm waiting for a box to reboot... ;)

> gettimeofday(&tv1,NULL);

        int rc;
        if (!(rc = gettimeofday(&tv1,NULL)) {
                printf ("gettimeofday 1 failed, rc=%d errno=%d\n",rc,errno);
        }
> gettimeofday(&tv2,NULL);
        if (!(rc = gettimeofday(&tv2,NULL)) {
                printf ("gettimeofday 2 failed, rc=%d errno=%d\n",rc,errno);
        }

Always check return codes. gettimeofday() *can* fail (most likely,
tv1 and/or tv2 are bum pointers that don't point where you think).

> Anyone knows why?

If both calls are actually succeeding, you might want to do this:

        printf("tv1=%d.%d 
tv2=%d.%d\n",tv1.tv_sec,tv1.tv_usec,tv2.tv_sec,tv2.tv_usec);

So you can see which valye is bogus (rather than trying to look at the 
difference
and tell from that...)

Attachment: pgp1A2J5w0jSU.pgp
Description: PGP signature

_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to