This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

clock_t & return -1


# ------ man clock (fragments) ------
# NAME
#        `clock'--cumulative processor time
#
#
# SYNOPSIS
#         include <time.h>
#         clock_t clock(void);
#
# RETURNS
#        The amount of processor time used so far by your program, in units
#        defined by the machine-dependent macro `CLOCKS_PER_SEC'.
#        If no measurement is available, the result is `-1'.
#
# -----------------------------------


------ C code : File t.c ------
#include <time.h>
int main()
{
  return (!(clock () == -1));
}
-------------------------------


------ Compilation ------

$ gcc -W -Wall t.c

t.c: In function `main':
t.c:4: warning: comparison between signed and unsigned

-------------------------

So, clock() is unsigned and never returns -1 (?!)

If one must write
  ----------------------------------
  if (!(clock () == (clock_t)(-1)));
  ----------------------------------
  I think it is worth noting that in the manual.


--
 =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
     news://news.gmane.org/gmane.comp.lang.c++.perfometer
   =====================================






--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]