Skip to content

Instantly share code, notes, and snippets.

@shulima
Created March 25, 2015 22:39
Show Gist options
  • Save shulima/d851f8f35526db5e2fe9 to your computer and use it in GitHub Desktop.
Save shulima/d851f8f35526db5e2fe9 to your computer and use it in GitHub Desktop.
Monkey-patch program_name into gnulib
diff --git a/gnulib/lib/error.c b/gnulib/lib/error.c
index 18ff5db..d8c5acb 100644
--- a/gnulib/lib/error.c
+++ b/gnulib/lib/error.c
@@ -113,9 +113,13 @@ int strerror_r ();
# endif
# endif
+#if defined __APPLE__ && defined __MACH__
+#define program_name (((char **)*_NSGetArgv())[0])
+#else
/* The calling program should define program_name and set it to the
name of the executing program. */
extern char *program_name;
+#endif
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment