Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jan 2013 10:21:03 -0800
From:      Michael Sierchio <kudzu@tenebras.com>
To:        "Thomas D. Dean" <tomdean@speakeasy.org>
Cc:        "questions@FreeBSD.org" <questions@freebsd.org>
Subject:   Re: time_t definition
Message-ID:  <CAHu1Y71L0fuQPgN044-GDr8NBPAo=n%2B6HSBv7Zi%2ByXTceYTZCA@mail.gmail.com>
In-Reply-To: <50F6EDFB.70501@speakeasy.org>
References:  <50F5A189.7000701@speakeasy.org> <20130116120015.3b8d0db4@mr129166> <50F6EDFB.70501@speakeasy.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Top posting for brevity - the fact is, the code in your original
example is wrong.  There are reasons to complain about argument size
mismatches, esp. in print functions that call (versions of) malloc.
You should cast the time_t value explicitly, or use %d instead of %ld.

- M

On Wed, Jan 16, 2013 at 10:14 AM, Thomas D. Dean <tomdean@speakeasy.org> wrote:
> 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.
>
>
> #include <stdio.h>
> 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.
>
> 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????
>
> Tom Dean
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHu1Y71L0fuQPgN044-GDr8NBPAo=n%2B6HSBv7Zi%2ByXTceYTZCA>