tzcode2007h.tar.gz - Functions defined with prototypes and C99 features?
Erik van der Poel
erikv at google.com
Tue Nov 6 17:44:57 UTC 2007
On a somewhat related note, I find that if I don't apply the following
patch, I get a compiler warning:
diff -r -u /tmp/tz/localtime.c tz/localtime.c
--- /tmp/tz/localtime.c 2007-08-20 07:47:41.000000000 -0700
+++ tz/localtime.c 2007-11-06 09:35:20.712010000 -0800
@@ -328,7 +328,7 @@
if (TYPE_INTEGRAL(time_t) &&
TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
return 0;
- return t1 - t0 == SECSPERREPEAT;
+ return ((int_fast64_t) t1) - t0 == SECSPERREPEAT;
}
static int
This is the warning that I get:
tz/localtime.c: In function 'differ_by_repeat':
tz/localtime.c:331: warning: comparison is always false due to limited
range of data type
Would you please include this patch in the next release?
Thank you,
Erik van der Poel
On Nov 6, 2007 9:25 AM, Paul Eggert <eggert at cs.ucla.edu> wrote:
> "Jonathan Leffler" <jonathan.leffler at gmail.com> writes:
>
> > Is there actually a good reason not to write the whole library with ISO
> > prototypes?
>
> Not these days, no. Every practical C compiler supports prototypes
> nowadays. I think that stuff is now pedantic only, meant as
> illustration, to port back to ancient K&R compilers.
>
> As long as we're being pedantic, it might be worth mentioning that the
> current approach is not portable to arbitrary standard C platforms,
> since it assumes that time_t is at least as wide as int. C does not
> allow this:
>
> static int differ_by_repeat(time_t t1, time_t t0);
>
> static int
> differ_by_repeat(t1, t0)
> const time_t t1;
> const time_t t0;
> { ... }
>
> when time_t is of type 'short', say. (This is only a pedantic point
> as well, of course; nobody defines time_t to be that narrow.)
>
>
More information about the tz
mailing list