From 0408040ed75e3b933f19d27190581f40b8cb57d2 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 30 Jul 2020 19:26:28 +0800 Subject: [PATCH] Fix utest fail for C++11 or C++14 --- trunk/auto/utest.sh | 2 +- trunk/src/utest/srs_utest.hpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index e7ce6a4a1..f29d698ba 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -49,7 +49,7 @@ USER_DIR = . CPPFLAGS += -I\$(GTEST_DIR)/include # Flags passed to the C++ compiler. -CXXFLAGS += ${CXXFLAGS} -Wextra ${UTEST_EXTRA_DEFINES} +CXXFLAGS += ${CXXFLAGS} ${UTEST_EXTRA_DEFINES} -Wno-unused-private-field -Wno-unused-command-line-argument # All tests produced by this Makefile. Remember to add new tests you # created to the list. diff --git a/trunk/src/utest/srs_utest.hpp b/trunk/src/utest/srs_utest.hpp index bf2f26c8a..252c9928f 100644 --- a/trunk/src/utest/srs_utest.hpp +++ b/trunk/src/utest/srs_utest.hpp @@ -24,6 +24,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SRS_UTEST_PUBLIC_SHARED_HPP #define SRS_UTEST_PUBLIC_SHARED_HPP +// Before define the private/protected, we must include some system header files. +// Or it may fail with: +// redeclared with different access struct __xfer_bufptrs +// @see https://stackoverflow.com/questions/47839718/sstream-redeclared-with-public-access-compiler-error +#include "gtest/gtest.h" + // Public all private and protected members. #define private public #define protected public @@ -33,7 +39,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#include "gtest/gtest.h" #include using namespace std;