From owner-freebsd-questions@FreeBSD.ORG Wed Jan 16 18:38:27 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AA4275D8 for ; Wed, 16 Jan 2013 18:38:27 +0000 (UTC) (envelope-from bonomi@mail.r-bonomi.com) Received: from mail.r-bonomi.com (mx-out.r-bonomi.com [204.87.227.120]) by mx1.freebsd.org (Postfix) with ESMTP id 6B10F1B5 for ; Wed, 16 Jan 2013 18:38:26 +0000 (UTC) Received: (from bonomi@localhost) by mail.r-bonomi.com (8.14.4/rdb1) id r0GIfgWS054810; Wed, 16 Jan 2013 12:41:42 -0600 (CST) Date: Wed, 16 Jan 2013 12:41:42 -0600 (CST) From: Robert Bonomi Message-Id: <201301161841.r0GIfgWS054810@mail.r-bonomi.com> To: tomdean@speakeasy.org Subject: Re: time_t definition In-Reply-To: <50F6EDFB.70501@speakeasy.org> Cc: questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 18:38:27 -0000 > Date: Wed, 16 Jan 2013 10:14:19 -0800 > From: "Thomas D. Dean" > Subject: Re: time_t definition > > On 01/16/13 03:00, Patrick Lamaiziere wrote: > > > Looks like gcc47 checks the printf format string (-Wformat) > > Disable this check or convert your time_t. > > Yes, I know gcc47 checks the format string. > > But, time_t is of type int32, from a typedef statement. *precisely* and the format string had "%ld". this IS a type mismatch, if a 'long' is a 64-bit value. > #include > typedef int zzz; > typedef zzz yyy; > typedef yyy xxx; > int main() { > xxx idx; > for (idx=0; idx<10; idx++) printf("%d\n",idx); > return 0; > } > > does not produce the error (I did this on the 'other' system) > > gcc --version > gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 > ... > > > gcc -O2 -pipe -I../../include -std=gnu99 -fstack-protector > -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized > -Wno-pointer-sign xxx.c -o xxx > > I did not think to do this on the FreeBSD system I was using yesterday. > > What I don't understand is where gcc is losing track of this definition. It *isn't*. > > In 9.0, or maybe earlier, the definition of time_t was changed with a > view toward 64-bit systems. I remember a statement to the effect of "in > 2038, 32-bit time will overflow. It is unlikely that many 32-biot > systems will be around then. So, making the change to 64-bit now will > prevent having to do it in the future". > > So, now, it seems that any calculation involving time_t requires a cast???? FALSE. Calculation is OK. I/O format conversion is problematic.