Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: "Alex Vinokur" Subject: clock_t & return -1 Date: Tue, 14 Oct 2003 19:31:45 +0200 Lines: 55 Message-ID: X-Complaints-To: usenet AT sea DOT gmane DOT org X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 # ------ man clock (fragments) ------ # NAME # `clock'--cumulative processor time # # # SYNOPSIS # include # 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 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 AT connect DOT 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/