# HG changeset patch # User Bruno Haible # Date 1517385892 -3600 # Node ID c153a5913479882b4433a81c265cedabdf945bd2 # Parent 492d30539cc87385bcaed9af4fc7e6630c5f4401 environ: Fix link error on 64-bit Cygwin. * lib/unistd.in.h (environ): On Cygwin, redeclare with the __declspec(dllimport) attribute. * doc/posix-functions/environ.texi: Mention the Cygwin problem. diff -r 492d30539cc8 -r c153a5913479 ChangeLog --- a/ChangeLog Tue Jan 30 09:05:57 2018 +0100 +++ b/ChangeLog Wed Jan 31 09:04:52 2018 +0100 @@ -1,3 +1,10 @@ +2018-01-31 Bruno Haible + + environ: Fix link error on 64-bit Cygwin. + * lib/unistd.in.h (environ): On Cygwin, redeclare with the + __declspec(dllimport) attribute. + * doc/posix-functions/environ.texi: Mention the Cygwin problem. + 2018-01-30 Bruno Haible get-rusage-data: Add support for Minix 3. diff -r 492d30539cc8 -r c153a5913479 doc/posix-functions/environ.texi --- a/doc/posix-functions/environ.texi Tue Jan 30 09:05:57 2018 +0100 +++ b/doc/posix-functions/environ.texi Wed Jan 31 09:04:52 2018 +0100 @@ -24,6 +24,9 @@ #define environ (*_NSGetEnviron()) @end smallexample This works at all versions of Mac OS X. +@item +On Cygwin in 64-bit mode, references to this variable cause a link error when +the option @code{-Wl,--disable-auto-import} is in use. @end itemize Portability problems not fixed by Gnulib: diff -r 492d30539cc8 -r c153a5913479 lib/unistd.in.h --- a/lib/unistd.in.h Tue Jan 30 09:05:57 2018 +0100 +++ b/lib/unistd.in.h Wed Jan 31 09:04:52 2018 +0100 @@ -400,6 +400,13 @@ #if @GNULIB_ENVIRON@ +# if defined __CYGWIN__ +/* The 'environ' variable is defined in a DLL. Therefore its declaration needs + the '__declspec(dllimport)' attribute, but the system's lacks it. + This leads to a link error on 64-bit Cygwin when the option + -Wl,--disable-auto-import is in use. */ +_GL_EXTERN_C __declspec(dllimport) char **environ; +# endif # if !@HAVE_DECL_ENVIRON@ /* Set of environment variables and values. An array of strings of the form "VARIABLE=VALUE", terminated with a NULL. */