]> Savannah Git Hosting - gnulib.git/commitdiff
environ: Fix link error on 64-bit Cygwin.
authorBruno Haible <bruno@clisp.org>
Wed, 31 Jan 2018 08:04:52 +0000 (09:04 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Jan 2018 08:05:07 +0000 (09:05 +0100)
* lib/unistd.in.h (environ): On Cygwin, redeclare with the
__declspec(dllimport) attribute.
* doc/posix-functions/environ.texi: Mention the Cygwin problem.

ChangeLog
doc/posix-functions/environ.texi
lib/unistd.in.h

index ca0ea99b113f423d7879870eaaf5c3e99842f7ee..47566b7100caa5cdfd8096d097a5e83fa5dbacd8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-31  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        get-rusage-data: Add support for Minix 3.
index 34ac25ad82653104c2a09d67951861cb92b4b456..a6c00958da6a0ee53c5688f82eae833dc51f3340 100644 (file)
@@ -24,6 +24,9 @@ shared libraries on Mac OS X 10.5.  Here is a workaround: Instead, one can use
 #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:
index 6802e3b60c0e0a27b5a278ae5cc1a5d578370812..4ef0ffabb82031cb1cdd3f509eb5d3193c33cf2a 100644 (file)
@@ -400,6 +400,13 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
 
 
 #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 <unistd.h> 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.  */