diff options
author | Loo Rong Jie <loorongjie@gmail.com> | 2018-07-13 13:23:28 (GMT) |
---|---|---|
committer | Loo Rong Jie <loorongjie@gmail.com> | 2018-07-13 13:23:28 (GMT) |
commit | 3a8d744030e165dc7bebf70e4fbc44831059a79b (patch) | |
tree | 04b51c012803d2b7a22da62578a697ab09a2ca60 /googletest/include/gtest/internal/gtest-port.h | |
parent | b4d4438df9479675a632b2f11125e57133822ece (diff) | |
download | googletest-3a8d744030e165dc7bebf70e4fbc44831059a79b.zip googletest-3a8d744030e165dc7bebf70e4fbc44831059a79b.tar.gz googletest-3a8d744030e165dc7bebf70e4fbc44831059a79b.tar.bz2 |
Disable MSVC function deprecation when using Clang
Diffstat (limited to 'googletest/include/gtest/internal/gtest-port.h')
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index d5ec086..727b41f 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -325,6 +325,22 @@ # define GTEST_DISABLE_MSC_WARNINGS_POP_() #endif +// Clang on Windows does not understand MSVC's pragma warning. +// We need clang-specific way to disable function deprecation warning. +#ifdef __clang__ +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") +#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + _Pragma("clang diagnostic pop") +#else +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + #ifndef GTEST_LANG_CXX11 // gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a @@ -2483,7 +2499,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } // Functions deprecated by MSVC 8.0. -GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */) +GTEST_DISABLE_MSC_DEPRECATED_PUSH_() inline const char* StrNCpy(char* dest, const char* src, size_t n) { return strncpy(dest, src, n); @@ -2531,7 +2547,7 @@ inline const char* GetEnv(const char* name) { #endif } -GTEST_DISABLE_MSC_WARNINGS_POP_() +GTEST_DISABLE_MSC_DEPRECATED_POP_() #if GTEST_OS_WINDOWS_MOBILE // Windows CE has no C library. The abort() function is used in |