From 9f1116c62284b1830b5b6b56ef9ab9e105788d2d Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 1 Apr 2018 15:23:32 +0900 Subject: [PATCH] Put wcslen() into ::std namespace on OS/2 OS/2 kLIBC has wcslen(), but it is not in ::std namespace. This fixes the following compilation error. ----- [ 1%] Building CXX object googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o In file included from F:/lang/work/googletest/googletest.git/googletest/src/gtest-all.cc:46:0: F:/lang/work/googletest/googletest.git/googletest/src/gtest-printers.cc: In function 'void testing::internal::PrintTo(const wchar_t*, std::ostream*)': F:/lang/work/googletest/googletest.git/googletest/src/gtest-printers.cc:352:34: error: 'wcslen' is not a member of 'std' PrintCharsAsStringTo(s, std::wcslen(s), os); ^~~~~~ F:/lang/work/googletest/googletest.git/googletest/src/gtest-printers.cc:352:34: note: suggested alternative: In file included from f:/lang/gcc/usr/local730/include/c++/7.3.0/cwchar:44:0, from f:/lang/gcc/usr/local730/include/c++/7.3.0/bits/postypes.h:40, from f:/lang/gcc/usr/local730/include/c++/7.3.0/iosfwd:40, from f:/lang/gcc/usr/local730/include/c++/7.3.0/ios:38, from f:/lang/gcc/usr/local730/include/c++/7.3.0/ostream:38, from F:/lang/work/googletest/googletest.git/googletest/include/gtest/gtest.h:55, from F:/lang/work/googletest/googletest.git/googletest/src/gtest-all.cc:39: f:/lang/gcc/usr/include/wchar.h:153:8: note: 'wcslen' size_t wcslen(const wchar_t *) __pure; ^~~~~~ make.exe[2]: *** [googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1 ----- --- googletest/include/gtest/internal/gtest-port.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 426a6e8a..24b88ea1 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -402,6 +402,13 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; # include #endif // GTEST_OS_WINDOWS +#if GTEST_OS_OS2 +namespace std { +// OS/2 kLIBC has wcslen(), but it is not in ::std namespace. +using ::wcslen; +} +#endif + #if GTEST_OS_LINUX_ANDROID // Used to define __ANDROID_API__ matching the target NDK API level. # include // NOLINT