From 8c9cb958078b470e352a58f7f2d756544051e59b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 Feb 2016 12:36:17 -0800 Subject: [PROPOSED PATCH] Fix asctime_r warning with MS-Windows Problem reported by Ian Abbott in: http://mm.icann.org/pipermail/tz/2016-February/023291.html * Makefile (CFLAGS): Add comment about new -D option. * private.h (HAVE_DECL_ASCTIME_R): New macro. (asctime_r): Depend on this, not on HAVE_POSIX_DECLS. --- Makefile | 1 + private.h | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 20c2c98..5e2fb52 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ LDLIBS= # Add the following to the end of the "CFLAGS=" line as needed. # -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c) +# -DHAVE_DECL_ASCTIME_R=0 if does not declare asctime_r # -DHAVE_DIRECT_H if mkdir needs (MS-Windows) # -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS) # -DHAVE_GETTEXT=1 if 'gettext' works (GNU, Linux, Solaris); also see LDLIBS diff --git a/private.h b/private.h index e23764d..941e91b 100644 --- a/private.h +++ b/private.h @@ -22,6 +22,10 @@ ** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'. */ +#ifndef HAVE_DECL_ASCTIME_R +#define HAVE_DECL_ASCTIME_R 1 +#endif + #ifndef HAVE_GETTEXT #define HAVE_GETTEXT 0 #endif /* !defined HAVE_GETTEXT */ @@ -386,17 +390,11 @@ time_t time(time_t *); void tzset(void); #endif -/* -** Some time.h implementations don't declare asctime_r. -** Others might define it as a macro. -** Fix the former without affecting the latter. -** Similarly for timezone, daylight, and altzone. -*/ +#if !HAVE_DECL_ASCTIME_R && !defined asctime_r +extern char *asctime_r(struct tm const *restrict, char *restrict); +#endif #if !HAVE_POSIX_DECLS -# ifndef asctime_r -extern char * asctime_r(struct tm const *restrict, char *restrict); -# endif # ifdef USG_COMPAT # ifndef timezone extern long timezone; -- 2.5.0