Date: Wed, 16 Jan 2013 12:00:15 +0100 From: Patrick Lamaiziere <patfbsd@davenulle.org> To: "Thomas D. Dean" <tomdean@speakeasy.org> Cc: "questions@FreeBSD.org" <questions@FreeBSD.org> Subject: Re: time_t definition Message-ID: <20130116120015.3b8d0db4@mr129166> In-Reply-To: <50F5A189.7000701@speakeasy.org> References: <50F5A189.7000701@speakeasy.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Le Tue, 15 Jan 2013 10:35:53 -0800, "Thomas D. Dean" <tomdean@speakeasy.org> 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.h> /* time_t */ > #include <sys/time.h> /* 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130116120015.3b8d0db4>