On 05/16/2011 04:04 PM, Sam Steingold wrote: > does importing the environ module mean that I can remove this: > > #if !HAVE_DECL_ENVIRON > extern_C char** environ; > #endif > > from my sources and assume that environ is properly declared in unistd?
Well, POSIX doesn't require <unistd.h> to declare environ; but since it
is a common glibc extension when _GNU_SOURCE is defined, yes, our
<unistd.h> replacement header guarantees it.
>
> also, how can I come up with the answer to this question myself without
> bothering you?
The preferred method is by reading the documentation:
From doc/posix-functions/environ.texi:
Gnulib module: environ
Portability problems fixed by Gnulib:
@itemize
@item
POSIX does not require this variable to be declared, and it is indeed not
declared on some platforms:
MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, IRIX 6.5, Solaris 11
2010-11.
Or you can look in lib/unistd.in.h. Note that there is a section:
#if @GNULIB_ENVIRON@
# if !@HAVE_DECL_ENVIRON@
/* Set of environment variables and values. An array of strings of the form
"VARIABLE=VALUE", terminated with a NULL. */
# if defined __APPLE__ && defined __MACH__
# include <crt_externs.h>
# define environ (*_NSGetEnviron ())
# else
# ifdef __cplusplus
extern "C" {
# endif
extern char **environ;
that is; if you are using the gnulib environ module, then there will be
a declaration for environ in the replacement header (either by including
other headers, or by direct declaration).
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
