diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dd38ad..473e9b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,7 @@ set(JSON_C_HEADERS
./json_util.h
./linkhash.h
./math_compat.h
+ ./strdup_compat.h
./printbuf.h
./random_seed.h
)
diff --git a/Makefile.am b/Makefile.am
index 41b9e6e..64b1a3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,6 +32,7 @@ libjson_cinclude_HEADERS = \
json_visit.h \
linkhash.h \
math_compat.h \
+ strdup_compat.h \
printbuf.h \
random_seed.h
diff --git a/json-c.vcxproj b/json-c.vcxproj
index 8a4f265..ab7b5e1 100644
--- a/json-c.vcxproj
+++ b/json-c.vcxproj
@@ -151,6 +151,7 @@ copy json_config.h.win32 json_config.h
+
@@ -164,4 +165,4 @@ copy json_config.h.win32 json_config.h
-
\ No newline at end of file
+
diff --git a/json-c.vcxproj.filters b/json-c.vcxproj.filters
index 67ff360..3c6f43d 100644
--- a/json-c.vcxproj.filters
+++ b/json-c.vcxproj.filters
@@ -80,6 +80,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -93,4 +96,4 @@
-
\ No newline at end of file
+
diff --git a/json_object.c b/json_object.c
index 8a70b5d..c65941e 100644
--- a/json_object.c
+++ b/json_object.c
@@ -29,13 +29,7 @@
#include "json_object_private.h"
#include "json_util.h"
#include "math_compat.h"
-
-#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
- /* MSC has the version as _strdup */
-# define strdup _strdup
-#elif !defined(HAVE_STRDUP)
-# error You do not have strdup on your system.
-#endif /* HAVE_STRDUP */
+#include "strdup_compat.h"
#if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
/* MSC has the version as _snprintf */
diff --git a/json_pointer.c b/json_pointer.c
index 582ca28..9cf3f16 100644
--- a/json_pointer.c
+++ b/json_pointer.c
@@ -16,6 +16,7 @@
#include
#include "json_pointer.h"
+#include "strdup_compat.h"
/**
* JavaScript Object Notation (JSON) Pointer
diff --git a/json_tokener.c b/json_tokener.c
index 65652f4..6ddea11 100644
--- a/json_tokener.c
+++ b/json_tokener.c
@@ -31,6 +31,7 @@
#include "json_object.h"
#include "json_tokener.h"
#include "json_util.h"
+#include "strdup_compat.h"
#ifdef HAVE_LOCALE_H
#include
@@ -41,13 +42,6 @@
#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
-#if !HAVE_STRDUP && defined(_MSC_VER)
- /* MSC has the version as _strdup */
-# define strdup _strdup
-#elif !HAVE_STRDUP
-# error You do not have strdup on your system.
-#endif /* HAVE_STRDUP */
-
#if !HAVE_STRNCASECMP && defined(_MSC_VER)
/* MSC has the version as _strnicmp */
# define strncasecmp _strnicmp
diff --git a/strdup_compat.h b/strdup_compat.h
new file mode 100644
index 0000000..51af81e
--- /dev/null
+++ b/strdup_compat.h
@@ -0,0 +1,11 @@
+#ifndef __strdup_compat_h
+#define __strdup_compat_h
+
+#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
+ /* MSC has the version as _strdup */
+# define strdup _strdup
+#elif !defined(HAVE_STRDUP)
+# error You do not have strdup on your system.
+#endif /* HAVE_STRDUP */
+
+#endif