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
// Environment
// ----------------------------------------------------------------------------
// 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;
bool wxGetEnvMap(wxEnvVariableHashMap *map)
{
wxCHECK_MSG( map, false, wxS("output pointer can't be NULL") );
#if defined(__VISUALC__)
wxChar **env = _tenviron;
+#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.
// Not sure if other compilers have _tenviron so use the (more standard)
// ANSI version only for them.