[program_options] Darwin failure help?

The program options library now fails a single test on Darwin, with this output: ../libs/program_options/test/parsers_test.cpp(205): fatal error in "call_test_main": test p.options.size() == 1 failed *** 1 failure detected in test case "call_test_main" The code in question is: putenv("PO_TEST_FOO=1"); parsed_options p = parse_environment(desc, "PO_TEST_"); BOOST_REQUIRE(p.options.size() == 1); So, it seems that after "putenv", the string is is not available in the 'environ' variable. The variable is declared like this: #if defined(__APPLE__) && defined(__DYNAMIC__) #include <crt_externs.h> static char** environ = *_NSGetEnviron(); #else extern char** environ; #endif The Darwin-specific conditinal was sent by Michael LaSpina, so I don't know what it really does, and so don't know why the test fails. I'd appreciate any suggestions. Thanks in advance, Volodya

Oops, my original patch was incorrect, in shared libraries on Darwin one must call _NSGetEnviron() to get the current environment. Changing static char** environ = *_NSGetEnviron(); to #define environ (*_NSGetEnviron()) cleared up the problem on my end. I was able to get some better details on the root of the initial problem here: http://lists.gnu.org/archive/html/bug-guile/2004-01/msg00013.html -Mike Vladimir Prus wrote:
The program options library now fails a single test on Darwin, with this output:

Michael LaSpina wrote:
Oops, my original patch was incorrect, in shared libraries on Darwin one must call _NSGetEnviron() to get the current environment. Changing
static char** environ = *_NSGetEnviron();
to
#define environ (*_NSGetEnviron())
cleared up the problem on my end.
Interesting, I though _NSGetEnviron returns the pointer to the same environment which is modified by putenv... Thanks for solving this problem! I've comitted the change from variable to define. Thanks, Volodya
participants (2)
-
Michael LaSpina
-
Vladimir Prus