Bug 14625

Summary: D-Bus doesn't link on Mac OS X
Product: dbus Reporter: Harald Fernengel <harry>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED DUPLICATE QA Contact: John (J5) Palmieri <johnp>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:

Description Harald Fernengel 2008-02-22 13:56:12 UTC
for some reason, "char **environ" cannot be extern'ed when building a library on Mac OS X. The patch below uses the suggested workaround according to the man page (using _NSGetEnviron()).

--- dbus-sysdeps.c	2008-01-14 20:51:51.000000000 +0100
+++ dbus-sysdeps.c.new	2008-02-22 22:12:34.000000000 +0100
@@ -47,6 +47,11 @@
 #include <errno.h>
 #endif
 
+#ifdef __APPLE__
+/* needed for _NSGetEnviron */
+#include <crt_externs.h>
+#endif
+
 _DBUS_DEFINE_GLOBAL_LOCK (win_fds);
 _DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache);
 _DBUS_DEFINE_GLOBAL_LOCK (system_users);
@@ -191,7 +196,12 @@
   if (clearenv () != 0)
      rc = FALSE;
 #else
+#ifdef __APPLE__
+/* On Mac OS X, environ can't be accessed directly - use _NSGetEnviron() instead */
+  char **environ = *_NSGetEnviron();
+#else
   extern char **environ;
+#endif
 
   if (environ != NULL)
     environ[0] = NULL;
Comment 1 John (J5) Palmieri 2008-03-04 07:27:26 UTC
AH_VERBATIM in the in bug 14260 is a cleaner way of dealing with this

*** This bug has been marked as a duplicate of bug 14260 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.