]> git.saurik.com Git - wxWidgets.git/commitdiff
Compilation fix: don't use "environ" under OS X.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 25 Oct 2010 09:22:19 +0000 (09:22 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 25 Oct 2010 09:22:19 +0000 (09:22 +0000)
The global environ variable is not directly accessible under OS X, use
_NSGetEnviron() instead.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65918 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/utilscmn.cpp

index 5176c5236ff598898ad50a466e92115d7523ef96..48e1549e7e1d0a0d0de2564f068cdb19b3b87ff1 100644 (file)
@@ -547,16 +547,28 @@ wxString wxGetCurrentDir()
 // Environment
 // ----------------------------------------------------------------------------
 
+#ifdef __WXOSX__
+    #include <crt_externs.h>
+#endif
+
 bool wxGetEnvMap(wxEnvVariableHashMap *map)
 {
     wxCHECK_MSG( map, false, wxS("output pointer can't be NULL") );
 
 #if defined(__VISUALC__)
     wxChar **env = _tenviron;
-#else // non-MSVC
+#elif defined(__WXOSX__)
+    // Under Mac shared libraries don't have access to the global environ
+    // variable so use this Mac-specific function instead as advised by
+    // environ(7) under Darwin
+    char ***penv = _NSGetEnviron();
+    if ( !penv )
+        return false;
+    char **env = *penv;
+#else // non-MSVC non-Mac
     // Not sure if other compilers have _tenviron so use the (more standard)
     // ANSI version only for them.
-    char ** env = environ;
+    char **env = environ;
 #endif
 
     if ( env )