Skip to content

Commit 73b8e17

Browse files
Gregory C. Sharpjcfr
authored andcommitted
COMP: Update json_(reader|writer).cpp to fix gcc6 build error
This commit backports open-source-parsers/jsoncpp@e105003 and fixes error like this one: ``` /path/to/JsonCpp/src/lib_json/json_reader.cpp:47:14: error: ‘scoped_ptr’ in namespace ‘std’ does not name a template type typedef std::scoped_ptr<CharReader> const CharReaderPtr; ^~~~~~~~~~ /path/to/JsonCpp/src/lib_json/json_reader.cpp: In function ‘bool Json::parseFromStream(const Json::CharReader::Factory&, std::istream&, Json::Value*, std::__cxx11::string*)’: /path/to/JsonCpp/src/lib_json/json_reader.cpp:1820:3: error: ‘CharReaderPtr’ was not declared in this scope CharReaderPtr const reader(fact.newCharReader()); ^~~~~~~~~~~~~ /path/to/JsonCpp/src/lib_json/json_reader.cpp:1821:10: error: ‘reader’ was not declared in this scope return reader->parse(begin, end, root, errs); ^~~~~~ /path/to/JsonCpp/src/lib_json/json_reader.cpp:1811:32: warning: unused parameter ‘fact’ [-Wunused-parameter] CharReader::Factory const& fact, std::istream& sin, ^~~~ ``` See http://slicer-devel.65872.n3.nabble.com/Slicer-gcc-6-tt4038282.html and http://na-mic.org/Mantis/view.php?id=4268
1 parent f4afa75 commit 73b8e17

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static int stackDepth_g = 0; // see readValue()
4343

4444
namespace Json {
4545

46-
#if __GNUC__ >= 6
47-
typedef std::scoped_ptr<CharReader> const CharReaderPtr;
46+
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
47+
typedef std::unique_ptr<CharReader> CharReaderPtr;
4848
#else
4949
typedef std::auto_ptr<CharReader> CharReaderPtr;
5050
#endif

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454

5555
namespace Json {
5656

57-
#if __GNUC__ >= 6
58-
typedef std::scoped_ptr<StreamWriter> const StreamWriterPtr;
57+
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
58+
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
5959
#else
6060
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
6161
#endif

0 commit comments

Comments
 (0)