From owner-freebsd-questions@FreeBSD.ORG Wed Jan 16 11:00:26 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 125435CD for ; Wed, 16 Jan 2013 11:00:26 +0000 (UTC) (envelope-from patfbsd@davenulle.org) Received: from smtp.lamaiziere.net (net.lamaiziere.net [94.23.254.147]) by mx1.freebsd.org (Postfix) with ESMTP id C08E0D89 for ; Wed, 16 Jan 2013 11:00:25 +0000 (UTC) Received: from mr129166.localdomain (mr129166.cri.univ-rennes1.fr [129.20.129.166]) by smtp.lamaiziere.net (Postfix) with ESMTPA id 69D30A910; Wed, 16 Jan 2013 12:00:17 +0100 (CET) Received: from mr129166 (localhost [127.0.0.1]) by mr129166.localdomain (Postfix) with ESMTP id 49B7062F9; Wed, 16 Jan 2013 12:00:16 +0100 (CET) Date: Wed, 16 Jan 2013 12:00:15 +0100 From: Patrick Lamaiziere To: "Thomas D. Dean" Subject: Re: time_t definition Message-ID: <20130116120015.3b8d0db4@mr129166> In-Reply-To: <50F5A189.7000701@speakeasy.org> References: <50F5A189.7000701@speakeasy.org> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.6; amd64-portbld-freebsd9) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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 11:00:26 -0000 Le Tue, 15 Jan 2013 10:35:53 -0800, "Thomas D. Dean" a écrit : Hello, > I am attempting to recompile some code from an older version. > > > uname -a > FreeBSD ZD7000 9.1-STABLE FreeBSD 9.1-STABLE #1: Sun Jan 13 23:44:33 > PST 2013 root@ZD7000:/usr/obj/usr/src/sys/GENERIC i386 > > > make > gcc47 -O2 -pipe -I../../include -std=gnu99 -fstack-protector > -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized > -Wno-pointer-sign -c data-collection.c > data-collection.c: In function 'main': > data-collection.c:214:4: error: format '%ld' expects argument of type > 'long int', but argument 3 has type 'time_t' [-Werror=format] > data-collection.c:234:4: error: format '%ld' expects argument of type > 'long int', but argument 3 has type 'time_t' [-Werror=format] > cc1: all warnings being treated as errors > *** [data-collection.o] Error code 1 > > > > cat data-collection.c > ... > #include /* time_t */ > #include /* gettimeofday() */ > ... > gettimeofday(&spi_stop, &tz); / * line 211 */ > printf("Loop %d, SPI %ld %ld\n", > loop, > spi_stop.tv_sec, spi_stop.tv_usec); > ... > gettimeofday(&disk_stop, &tz); /* line 231 */ > printf("Loop %d, Disk %ld %ld\n", > loop, > disk_stop.tv_sec, disk_stop.tv_usec); > ... > > time.h defines time_t > > #ifndef _TIME_T_DECLARED > typedef __time_t time_t; > #define _TIME_T_DECLARED > #endif > > sys/time.h includes sys/types.h which includes sys/_types.h which > includes machine/_types.h where __time_t is defined > > typedef __int32_t __time_t; /* time()... */ > > Question: Why do I see the error? Looks like gcc47 checks the printf format string (-Wformat) Disable this check or convert your time_t. Regards.