From b21b1378053285b3204857e87879fb3dc0197f8d Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Wed, 15 Feb 2012 20:44:54 -0600 Subject: [PATCH] Include json_inttypes.h in json_object.h since we use types like int32_t in the API and some systems need that header to compile. As part of this create a public json_config.h with a custom define to decide whether to include inttypes.h to avoid conflicting with other projects config.h header. --- Makefile.am | 6 ++++++ config.h.in | 12 +++++++++++- configure.in | 2 ++ json_config.h.in | 3 +++ json_inttypes.h | 4 +++- json_object.h | 2 ++ 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 json_config.h.in diff --git a/Makefile.am b/Makefile.am index 0e8b303..e31da77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,7 @@ libjsoninclude_HEADERS = \ bits.h \ debug.h \ json.h \ + json_config.h \ json_inttypes.h \ json_object.h \ json_object_private.h \ @@ -21,6 +22,11 @@ libjsoninclude_HEADERS = \ linkhash.h \ printbuf.h +#libjsonx_includedir = $(libdir)/json-c-@VERSION@ +# +#libjsonx_include_HEADERS = \ +# json_config.h + libjson_la_LDFLAGS = -version-info 1:0:1 -no-undefined libjson_la_SOURCES = \ diff --git a/config.h.in b/config.h.in index 83ab797..04f5dc5 100644 --- a/config.h.in +++ b/config.h.in @@ -80,6 +80,13 @@ /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG +/* Public define for json_inttypes.h */ +#undef JSON_C_HAVE_INTTYPES_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + /* Name of package */ #undef PACKAGE @@ -95,6 +102,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION @@ -113,5 +123,5 @@ /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc -/* Define to `unsigned' if does not define. */ +/* Define to `unsigned int' if does not define. */ #undef size_t diff --git a/configure.in b/configure.in index 7e2bbc8..7334319 100644 --- a/configure.in +++ b/configure.in @@ -11,8 +11,10 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) # Checks for header files. AM_CONFIG_HEADER(config.h) +AM_CONFIG_HEADER(json_config.h) AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/param.h] stdarg.h) +AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/json_config.h.in b/json_config.h.in new file mode 100644 index 0000000..7888e02 --- /dev/null +++ b/json_config.h.in @@ -0,0 +1,3 @@ + +/* Define to 1 if you have the header file. */ +#undef JSON_C_HAVE_INTTYPES_H diff --git a/json_inttypes.h b/json_inttypes.h index 1f3e4d2..b71bb09 100644 --- a/json_inttypes.h +++ b/json_inttypes.h @@ -2,6 +2,8 @@ #ifndef _json_inttypes_h_ #define _json_inttypes_h_ +#include "json_config.h" + #if defined(_MSC_VER) && _MSC_VER < 1600 /* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */ @@ -14,7 +16,7 @@ typedef __int64 int64_t; #else -#ifdef HAVE_INTTYPES_H +#ifdef JSON_C_HAVE_INTTYPES_H #include #endif /* inttypes.h includes stdint.h */ diff --git a/json_object.h b/json_object.h index d56d12c..e4f4c45 100644 --- a/json_object.h +++ b/json_object.h @@ -12,6 +12,8 @@ #ifndef _json_object_h_ #define _json_object_h_ +#include "json_inttypes.h" + #ifdef __cplusplus extern "C" { #endif -- 2.40.0