Skip to content

Commit

Permalink
Don't forward declare environ on Windows
Browse files Browse the repository at this point in the history
That seems to interact poorly with the environ and _environ macros
defined in MSVC's <stdlib.h>.

Also remove the incorrect comment about _NSGetEnviron().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180200 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rnk committed Apr 24, 2013
1 parent 84875ba commit 268adf2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions unittests/Support/ProgramTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "gtest/gtest.h"

#include <stdlib.h>
#ifdef __APPLE__
#if defined(__APPLE__)
# include <crt_externs.h>
#else
#elif !defined(_MSC_VER)
// Forward declare environ in case it's not provided by stdlib.h.
extern char **environ;
#endif
Expand All @@ -32,8 +32,6 @@ ProgramTestStringArg2("program-test-string-arg2");

static void CopyEnvironment(std::vector<const char *> &out) {
#ifdef __APPLE__
// _NSGetEnviron() only works from the main exe on Mac. Fortunately the test
// should be in the executable.
char **envp = *_NSGetEnviron();
#else
// environ seems to work for Windows and most other Unices.
Expand Down

0 comments on commit 268adf2

Please sign in to comment.