This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: 'char **environ' woes with cygwin
- To: gdb at sources dot redhat dot com
- Subject: Re: 'char **environ' woes with cygwin
- From: Eli Zaretskii <eliz at delorie dot com>
- Date: Fri, 25 Aug 2000 04:17:21 -0400 (EDT)
- References: <20000824163339.A9295@cygnus.com>
- Reply-to: Eli Zaretskii <eliz at is dot elta dot co dot il>
> From: Chris Faylor <cgf@cygnus.com>
> Date: Thu, 24 Aug 2000 16:33:39 -0400
>
> I've recently painfully learned that gdb explicitly declares 'char **environ'
> all over the place.
I see "extern char **environ", not "char **environ", the only
exception being kdb-start.c.
> This presents a problem for cygwin since environ is now being imported from
> the cygwin DLL.
Could you please explain more why is this a problem. I'm afraid I
don't know enough about the Cygwin DLL to get the idea.
> I've modified configure.in to egrep unistd.h for an environ declaration and
> define HAVE_ENVIRON if unistd.h contains a declaration.
What about systems where environ is declared in some other header?
> The question is, where do I put a:
>
> #ifndef HAVE_ENVIRON
> char **environ;
> #endif
This would probably break some ports, at least the DJGPP one (unless
I'm missing something): the DJGPP startup code includes this
definition, but no DJGPP header declares environ. So we will wind up
having multiple definitions at link time.
I think HAVE_ENVIRON cannot be based on examining the headers alone;
you must link a test program which says "extern char **environ" and
tries to access environ: if linking succeeds, you can define
HAVE_ENVIRON. The program needs to include unistd.h and any other
header which might declare environ.