[tz] [PROPOSED 3/4] Deprecate any asctime and ctime substitutes in C23
Paul Eggert
eggert at cs.ucla.edu
Wed Nov 30 19:25:51 UTC 2022
If C23, deprecate any substitutes for asctime and ctime,
since C23 deprecates the originals.
* private.h (ATTRIBUTE_DEPRECATED, DEPRECATED_IN_C23): New macros.
Use the latter on asctime and ctime.
---
private.h | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/private.h b/private.h
index b5fdf5a..4a1f667 100644
--- a/private.h
+++ b/private.h
@@ -440,6 +440,19 @@ typedef unsigned long uintmax_t;
# define HAVE___HAS_C_ATTRIBUTE false
#endif
+#if HAVE___HAS_C_ATTRIBUTE
+# if __has_c_attribute(deprecated)
+# define ATTRIBUTE_DEPRECATED [[deprecated]]
+# endif
+#endif
+#ifndef ATTRIBUTE_DEPRECATED
+# if 3 < __GNUC__ + (2 <= __GNUC_MINOR__)
+# define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
+# else
+# define ATTRIBUTE_DEPRECATED /* empty */
+# endif
+#endif
+
#if HAVE___HAS_C_ATTRIBUTE
# if __has_c_attribute(fallthrough)
# define ATTRIBUTE_FALLTHROUGH [[fallthrough]]
@@ -624,9 +637,14 @@ typedef time_tz tz_time_t;
# define altzone tz_altzone
# endif
-char *asctime(struct tm const *);
+# if __STDC_VERSION__ < 202311
+# define DEPRECATED_IN_C23 /* empty */
+# else
+# define DEPRECATED_IN_C23 ATTRIBUTE_DEPRECATED
+# endif
+DEPRECATED_IN_C23 char *asctime(struct tm const *);
char *asctime_r(struct tm const *restrict, char *restrict);
-char *ctime(time_t const *);
+DEPRECATED_IN_C23 char *ctime(time_t const *);
char *ctime_r(time_t const *, char *);
double difftime(time_t, time_t) ATTRIBUTE_UNSEQUENCED;
size_t strftime(char *restrict, size_t, char const *restrict,
--
2.38.1
More information about the tz
mailing list