diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-08-19 18:16:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 18:16:03 (GMT) |
commit | 1778f2091e90c9cf36d0f7c01f3da5dd203db3a4 (patch) | |
tree | 5ca1063e0b6e4117e3592c74350d1d95cb595d04 | |
parent | d1c1aac78160ae31353d9fe1bb1171353986a4f1 (diff) | |
parent | 97274b1e9488e8814d978f164510a8bca52509f0 (diff) | |
download | googletest-1778f2091e90c9cf36d0f7c01f3da5dd203db3a4.zip googletest-1778f2091e90c9cf36d0f7c01f3da5dd203db3a4.tar.gz googletest-1778f2091e90c9cf36d0f7c01f3da5dd203db3a4.tar.bz2 |
Merge pull request #1347 from Burgch/fix-argc
Fix value pointed to by `_NSGetArgc()` on macOS.
-rw-r--r-- | googletest/src/gtest.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 2bcdfd1..a229549 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -138,6 +138,12 @@ # define vsnprintf _vsnprintf #endif // GTEST_OS_WINDOWS +#if GTEST_OS_MAC +#ifndef GTEST_OS_IOS +#include <crt_externs.h> +#endif +#endif + #if GTEST_HAS_ABSL #include "absl/debugging/failure_signal_handler.h" #include "absl/debugging/stacktrace.h" @@ -5825,6 +5831,17 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { // other parts of Google Test. void ParseGoogleTestFlagsOnly(int* argc, char** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); + + // Fix the value of *_NSGetArgc() on macOS, but iff + // *_NSGetArgv() == argv + // Only applicable to char** version of argv +#if GTEST_OS_MAC +#ifndef GTEST_OS_IOS + if (*_NSGetArgv() == argv) { + *_NSGetArgc() = *argc; + } +#endif +#endif } void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); |