'char **environ' woes with cygwin
Eli Zaretskii
eliz@delorie.com
Fri Aug 25 01:17:00 GMT 2000
> 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.
More information about the Gdb
mailing list