zsh-workers
 help / color / mirror / code / Atom feed
* strptime() on Cygwin requires _XOPEN_SOURCE
@ 2016-07-16  5:34 Jun T.
  2016-07-18  8:41 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Jun T. @ 2016-07-16  5:34 UTC (permalink / raw)
  To: zsh-workers

When building on the latest Cygwin, I get the following warning:

datetime.c:62:12: warning: implicit declaration of function 'strptime'

and if I use the newly built zsh to run
zsh% zmodload zsh/datetime
zsh% strftime -r '%Y' 2016
then the zsh coredumps.

Cygwin uses not glib but newlib, and feature test macros have been
overhauled in newlib-2.4 (a few months ago I guess).
It now requires _XOPEN_SOURCE to use strptime(3) in time.h.

A possible fix is to define _XOPEN_SOURCE in datetime.c (patch1 below).
Another possibility is to define _GNU_SOURCE in zsh_system.h (patch2).

Both work OK on the latest Cygwin, but I can't test on older Cygwin.
Maybe patch1 is better since it would have minimum side effects?

patch1:
diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c
index bb82c54..b924392 100644
--- a/Src/Modules/datetime.c
+++ b/Src/Modules/datetime.c
@@ -27,6 +27,9 @@
  *
  */
 
+#ifdef __CYGWIN__
+#define _XOPEN_SOURCE
+#endif
 #include "datetime.mdh"
 #include "datetime.pro"
 #include <time.h>


patch2:
diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 17c4c64..8e48a51 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -37,7 +37,7 @@
 #endif
 #endif
 
-#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || defined(LIBC_MUSL)
+#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || defined(LIBC_MUSL) || defined(__CYGWIN__)
 /*
  * Turn on numerous extensions.
  * This is in order to get the functions for manipulating /dev/ptmx.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: strptime() on Cygwin requires _XOPEN_SOURCE
  2016-07-16  5:34 strptime() on Cygwin requires _XOPEN_SOURCE Jun T.
@ 2016-07-18  8:41 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2016-07-18  8:41 UTC (permalink / raw)
  To: zsh-workers

On Sat, 16 Jul 2016 14:34:30 +0900
Jun T. <takimoto-j@kba.biglobe.ne.jp> wrote:
> A possible fix is to define _XOPEN_SOURCE in datetime.c (patch1 below).
> Another possibility is to define _GNU_SOURCE in zsh_system.h (patch2).
> 
> Both work OK on the latest Cygwin, but I can't test on older Cygwin.
> Maybe patch1 is better since it would have minimum side effects?

Probably, yes.  It's really hard to work out what effects a change in
the main header is going to do to all the variety of systems, even if
they're GNU based.

pws


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-18  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16  5:34 strptime() on Cygwin requires _XOPEN_SOURCE Jun T.
2016-07-18  8:41 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).