Skip to content

Commit

Permalink
Fix build of modperl under MacOS X, again
Browse files Browse the repository at this point in the history
(cherry picked from commit 4e5a45f)
  • Loading branch information
DarthGandalf committed Apr 14, 2014
1 parent 9fdeb58 commit 6727e96
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/modperl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <perl.h>
#include <XSUB.h>

#if defined(__APPLE__) && defined(__MACH__)
#include <crt_externs.h> // for _NSGetEnviron
#endif

#include "modperl/pstring.h"

using std::set;
Expand Down Expand Up @@ -67,10 +71,16 @@ class CModPerl: public CModule {
"-I", const_cast<char*>(sTmp.c_str()),
const_cast<char*>(sModPath.c_str()), NULL};
char **argv = pArgv;
PERL_SYS_INIT3(&argc, &argv, &environ);
char *** const pEnviron =
#if defined(__APPLE__) && defined(__MACH__)
_NSGetEnviron();
#else
&environ;
#endif
PERL_SYS_INIT3(&argc, &argv, pEnviron);
m_pPerl = perl_alloc();
perl_construct(m_pPerl);
if (perl_parse(m_pPerl, xs_init, argc, argv, environ)) {
if (perl_parse(m_pPerl, xs_init, argc, argv, *pEnviron)) {
sMessage = "Can't initialize perl. ";
if (SvTRUE(ERRSV)) {
sMessage += PString(ERRSV);
Expand Down

0 comments on commit 6727e96

Please sign in to comment.