From: Vadim Zeitlin Date: Mon, 25 Oct 2010 09:22:19 +0000 (+0000) Subject: Compilation fix: don't use "environ" under OS X. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1f4c7e791bed162fc1b6d3bc03d875f1b9790c15 Compilation fix: don't use "environ" under OS X. 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 --- diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 5176c5236f..48e1549e7e 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -547,16 +547,28 @@ wxString wxGetCurrentDir() // Environment // ---------------------------------------------------------------------------- +#ifdef __WXOSX__ + #include +#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 )