dlls/kernel/process.c breakage due to environ

Gerald Pfeifer pfeifer at dbai.tuwien.ac.at
Fri Oct 10 03:16:09 CDT 2003

My nightly autobuilder failed to build today, after I've had no
problems for several days.  This seems to be due to yesterday's
changes in dlls/kernel:

  process.o: In function `build_initial_environment':
  wine/dlls/kernel/process.c:341: undefined reference to `environ'
  wine/dlls/kernel/process.c:357: undefined reference to `environ'
  process.o: In function `build_envp':
  wine/dlls/kernel/process.c:1018: undefined reference to `environ'
  gmake[2]: *** [kernel32.dll.so] Error 1

Part of the fix is the patch below, but this is not sufficient, as
environ simply is non-standard.  On my SuSE 8.2 box, for example,
/usr/include/unistd.h says:

  #ifdef __USE_GNU
  extern char **environ;

In other words, on GNU/Linux you are just lucky because even if the
symbol is not declared (which is why you need the extern declaration)
it is in the library.


Declare environ at the top, not inside functions.

Index: process.c
RCS file: /home/wine/wine/dlls/kernel/process.c,v
retrieving revision 1.24
diff -u -3 -p -r1.24 process.c
--- process.c	10 Oct 2003 00:12:17 -0000	1.24
+++ process.c	10 Oct 2003 08:11:52 -0000
@@ -73,6 +73,8 @@ extern void SHELL_LoadRegistry(void);
 extern void VERSION_Init( const WCHAR *appname );
 extern void MODULE_InitLoadPath(void);

+extern char **environ;
  *           contains_path
@@ -331,7 +333,6 @@ static HMODULE load_pe_exe( const WCHAR
 static BOOL build_initial_environment(void)
-    extern char **environ;
     ULONG size = 1;
     char **e;
     WCHAR *p, *endptr;
@@ -1007,7 +1008,6 @@ static char **build_envp( const WCHAR *e

     if ((envp = malloc( count * sizeof(*envp) )))
-        extern char **environ;
         char **envptr = envp;
         char **unixptr = environ;
         char *p;

More information about the wine-devel mailing list