Torsten Bögershausen [off-list ref] writes:
On 2013-07-20 09.49, Benoit Sigoure wrote:
quoted
+#ifdef __APPLE__
+// On OS X libc headers don't define this symbol.
+extern char **environ;
+#endif
+
A more generic approach could be:
In the file "config.mak.uname": Define a variable in the Darwin section like this
NO_EXT_ENVIRON = UnfortunatelyYes
Actually, it is _wrong_ for us to rely on system header files to
define this symbol for us. Declaring "extern char **environ" is
responsibility of the user programs (like us).
When _GNU_SOURCE is defined glibc header (I think it is unistd.h)
seem to define it for us.
Perhaps the correct fix is to revert ec535cc2 for everybody, and if
MinGW needs such a workaround, do it inside #ifndef MINGW?
On Sat, Jul 20, 2013 at 10:53 PM, Junio C Hamano [off-list ref] wrote:
Actually, it is _wrong_ for us to rely on system header files to
define this symbol for us. Declaring "extern char **environ" is
responsibility of the user programs (like us).
Actually, that's right. The C99 standard doesn't mention anything
about `environ' (only 7.20.4.5 defines `getenv') and POSIX explicitly
states "the [environ] variable, which must be declared by the user if
it is to be used directly"
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/environ.html)
When _GNU_SOURCE is defined glibc header (I think it is unistd.h)
seem to define it for us.
Perhaps the correct fix is to revert ec535cc2 for everybody, and if
MinGW needs such a workaround, do it inside #ifndef MINGW?
That sounds right.
--
Benoit "tsuna" Sigoure
This reverts commit ec535cc27e6c4f5e0b1d157e04f5511f166ecd9d.
POSIX explicitly states "the [environ] variable, which
must be declared by the user if it is to be used directly".
Not declaring it causes compilation to fail on OS X.
Instead don't declare the variable on MinGW, as it causes
a spurious warning there.
---
compat/unsetenv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compat/unsetenv.c b/compat/unsetenv.c
index 4ea1856..bf5fd70 100644
--- a/compat/unsetenv.c
+++ b/compat/unsetenv.c
@@ -2,6 +2,9 @@
void gitunsetenv (const char *name)
{
+#if !defined(__MINGW32__)
+ extern char **environ;
+#endif
int src, dst;
size_t nmln;
--
1.8.2.1.539.g4196a96
This reverts commit ec535cc27e6c4f5e0b1d157e04f5511f166ecd9d.
POSIX explicitly states "the [environ] variable, which
must be declared by the user if it is to be used directly".
Not declaring it causes compilation to fail on OS X.
Instead don't declare the variable on MinGW, as it causes
a spurious warning there.
Signed-off-by: Benoit Sigoure <redacted>
---
Resending as I forgot to Sign-off the previous patch.
compat/unsetenv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compat/unsetenv.c b/compat/unsetenv.c
index 4ea1856..bf5fd70 100644
--- a/compat/unsetenv.c
+++ b/compat/unsetenv.c
@@ -2,6 +2,9 @@
void gitunsetenv (const char *name)
{
+#if !defined(__MINGW32__)
+ extern char **environ;
+#endif
int src, dst;
size_t nmln;
--
1.8.2.1.539.g4196a96