From ad6ad4ae1ecf963d36abcc85a190a655584b5499 Mon Sep 17 00:00:00 2001 From: Daniel Kopecek Date: Tue, 14 Apr 2015 16:02:49 +0200 Subject: [PATCH] Fix compilation of json_unit with GCC 5 Addressing: ``` + make json_unit g++ -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal -I src -I test -Dprivate=public test/unit.cpp -o json_unit In file included from test/catch.hpp:65:0, from test/unit.cpp:11: /usr/include/c++/5.0.0/sstream:300:7: error: 'struct std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>::__xfer_bufptrs' redeclared with different access struct __xfer_bufptrs ``` --- Makefile | 2 +- test/unit.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 74074209..b0a05490 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ clean: # build unit tests json_unit: test/unit.cpp src/json.hpp test/catch.hpp - $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test -Dprivate=public $< $(LDFLAGS) -o $@ + $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@ # create scanner with re2c re2c: src/json.hpp.re2c diff --git a/test/unit.cpp b/test/unit.cpp index d6b2b420..92360fb5 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -10,9 +10,6 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "json.hpp" -using nlohmann::json; - #include #include #include @@ -24,6 +21,10 @@ using nlohmann::json; #include #include +#define private public +#include "json.hpp" +using nlohmann::json; + TEST_CASE("constructors") { SECTION("create an empty value with a given type")