Skip to content

Commit d423c46

Browse files
committed
Expand pointer test to fix build on Clang as well.
Building in -Wall -Werror in c++11 mode errors on those auto_ptrs, at least on Clang 3.7.x on Debian Jessie.
1 parent 148201f commit d423c46

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace Json {
4545

4646
#if defined(JSON_USE_SCOPED_PTR)
4747
typedef std::scoped_ptr<CharReader> const CharReaderPtr;
48+
#elif defined(JSON_USE_UNIQUE_PTR)
49+
typedef std::unique_ptr<CharReader> const CharReaderPtr;
4850
#else
4951
typedef std::auto_ptr<CharReader> CharReaderPtr;
5052
#endif

src/lib_json/json_tool.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212
* It is an internal header that must not be exposed.
1313
*/
1414

15+
// Note that a C++ standard header must be included before this one (the code
16+
// below indicates that <string> would logically be included) in order to set
17+
// macros required to test for libstdc++
18+
1519
#if defined(__GNUC__) && (__GNUC__ >= 6)
1620
#define JSON_USE_SCOPED_PTR
21+
#elif defined(__clang__) && defined(__USE_ISOCXX11) && defined(__GLIBCXX__)
22+
// clang with libstdc++
23+
#define JSON_USE_UNIQUE_PTR
1724
#endif
1825

1926
namespace Json {

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ namespace Json {
5656

5757
#if defined(JSON_USE_SCOPED_PTR)
5858
typedef std::scoped_ptr<StreamWriter> const StreamWriterPtr;
59+
#elif defined(JSON_USE_UNIQUE_PTR)
60+
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
5961
#else
6062
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
6163
#endif

0 commit comments

Comments
 (0)