This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Fix a MinGW warning in libiberty/setenv.c
> Date: Wed, 13 Mar 2013 11:52:48 -0700
> From: Ian Lance Taylor <iant@google.com>
> Cc: gdb-patches@sourceware.org, dj@redhat.com, gcc-patches@gcc.gnu.org
>
> On 3/13/13, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > #ifdef __MSVCRT__
> > extern _CRTIMP char *** __cdecl __MINGW_NOTHROW __p__environ(void);
> > extern _CRTIMP wchar_t *** __cdecl __MINGW_NOTHROW
> > __p__wenviron(void);
> > # define _environ (*__p__environ())
> > # define _wenviron (*__p__wenviron())
> > #else /* ! __MSVCRT__ */
> > #endif /* ! __MSVCRT__ */
> >
> > #define environ _environ
>
> Cool.
>
> > and setenv.c does this:
> >
> > #ifndef HAVE_ENVIRON_DECL
> > extern char **environ;
> > #endif
> >
> > Solution: Add a guard:
>
> This is OK with a ChangeLog entry.
Thanks, committed thusly:
2013-03-17 Eli Zaretskii <eliz@gnu.org>
* setenv.c [!HAVE_ENVIRON_DECL]: Avoid declaring environ if it is
a macro, as this causes compiler warnings with MinGW.
Index: libiberty/setenv.c
===================================================================
RCS file: /cvs/src/src/libiberty/setenv.c,v
retrieving revision 1.10
diff -u -r1.10 setenv.c
--- libiberty/setenv.c 3 Feb 2011 07:23:59 -0000 1.10
+++ libiberty/setenv.c 17 Mar 2013 19:03:07 -0000
@@ -63,8 +63,11 @@
#define __environ environ
#ifndef HAVE_ENVIRON_DECL
+/* MinGW defines environ to call a function. */
+#ifndef environ
extern char **environ;
#endif
+#endif
#undef setenv
#undef unsetenv