Skip to content

Commit b21b137

Browse files
committedFeb 16, 2012
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.
1 parent 15db937 commit b21b137

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed
 

‎Makefile.am

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ libjsoninclude_HEADERS = \
1313
bits.h \
1414
debug.h \
1515
json.h \
16+
json_config.h \
1617
json_inttypes.h \
1718
json_object.h \
1819
json_object_private.h \
@@ -21,6 +22,11 @@ libjsoninclude_HEADERS = \
2122
linkhash.h \
2223
printbuf.h
2324

25+
#libjsonx_includedir = $(libdir)/json-c-@VERSION@
26+
#
27+
#libjsonx_include_HEADERS = \
28+
# json_config.h
29+
2430
libjson_la_LDFLAGS = -version-info 1:0:1 -no-undefined
2531

2632
libjson_la_SOURCES = \

‎config.h.in

+11-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@
8080
/* Define to 1 if you have the `vsyslog' function. */
8181
#undef HAVE_VSYSLOG
8282

83+
/* Public define for json_inttypes.h */
84+
#undef JSON_C_HAVE_INTTYPES_H
85+
86+
/* Define to the sub-directory in which libtool stores uninstalled libraries.
87+
*/
88+
#undef LT_OBJDIR
89+
8390
/* Name of package */
8491
#undef PACKAGE
8592

@@ -95,6 +102,9 @@
95102
/* Define to the one symbol short name of this package. */
96103
#undef PACKAGE_TARNAME
97104

105+
/* Define to the home page for this package. */
106+
#undef PACKAGE_URL
107+
98108
/* Define to the version of this package. */
99109
#undef PACKAGE_VERSION
100110

@@ -113,5 +123,5 @@
113123
/* Define to rpl_realloc if the replacement function should be used. */
114124
#undef realloc
115125

116-
/* Define to `unsigned' if <sys/types.h> does not define. */
126+
/* Define to `unsigned int' if <sys/types.h> does not define. */
117127
#undef size_t

‎configure.in

+2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
1111

1212
# Checks for header files.
1313
AM_CONFIG_HEADER(config.h)
14+
AM_CONFIG_HEADER(json_config.h)
1415
AC_HEADER_STDC
1516
AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/param.h] stdarg.h)
17+
AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])
1618

1719
# Checks for typedefs, structures, and compiler characteristics.
1820
AC_C_CONST

‎json_config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
/* Define to 1 if you have the <inttypes.h> header file. */
3+
#undef JSON_C_HAVE_INTTYPES_H

‎json_inttypes.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef _json_inttypes_h_
33
#define _json_inttypes_h_
44

5+
#include "json_config.h"
6+
57
#if defined(_MSC_VER) && _MSC_VER < 1600
68

79
/* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */
@@ -14,7 +16,7 @@ typedef __int64 int64_t;
1416

1517
#else
1618

17-
#ifdef HAVE_INTTYPES_H
19+
#ifdef JSON_C_HAVE_INTTYPES_H
1820
#include <inttypes.h>
1921
#endif
2022
/* inttypes.h includes stdint.h */

‎json_object.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef _json_object_h_
1313
#define _json_object_h_
1414

15+
#include "json_inttypes.h"
16+
1517
#ifdef __cplusplus
1618
extern "C" {
1719
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.