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 Message-ID: <051901c3927c$b7d0f2b0$cd8a9dc0@uk.aonix.com> From: "Cliff Hones" To: "Alex Vinokur" , References: Subject: Re: clock_t & return -1 Date: Tue, 14 Oct 2003 18:58:04 +0100 Organization: Aonix Europe MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Alex Vinokur wrote: >... > ------ 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 (?!) You can find the definition of the type clock_t in the relevant header. (It comes from _CLOCK_T_ in machine/types.h and is unsigned long.) So yes, technically, clock() cannot return -1. However, it is almost certain that the intention of the man page is to indicate that on error it returns the same bit pattern as (signed) -1, i.e. 0xfffffff or equivalently (clock_t)(-1). > If one must write > ---------------------------------- > if (!(clock () == (clock_t)(-1))); > ---------------------------------- > I think it is worth noting that in the manual. To be pedantic, and avoid the warning, one should write the test in this way, but the code generated will be identical, so if you don't mind the warning there is no need. -- Cliff -- 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/