This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: 'char **environ' woes with cygwin
> From: Chris Faylor <cgf@cygnus.com>
> Date: Fri, 25 Aug 2000 12:35:14 -0400
>
> So, for Windows, environ needs to be:
>
> extern char __declspec(dllimport) **environ;
I think some other packages I've seen define a preprocessor symbol
DLLIMPORT or some such, whose definition is empty for all platforms
except Windows.
Of course, your suggestion is okay as well.
> >> #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.
>
> Sorry. I should have added an extern.
>
> >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.
>
> I don't see why.
That's because I thought you *really* wanted to declare "char **environ"
instead of "extern char **environ". A misunderstanding.