Skip to content

Commit

Permalink
Include json_inttypes.h in json_object.h since we use types like int3…
Browse files Browse the repository at this point in the history
…2_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.
  • Loading branch information
hawicz committed Feb 16, 2012
1 parent 15db937 commit b21b137
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 = \
Expand Down
12 changes: 11 additions & 1 deletion config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

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

/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
2 changes: 2 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions json_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/* Define to 1 if you have the <inttypes.h> header file. */
#undef JSON_C_HAVE_INTTYPES_H
4 changes: 3 additions & 1 deletion json_inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -14,7 +16,7 @@ typedef __int64 int64_t;

#else

#ifdef HAVE_INTTYPES_H
#ifdef JSON_C_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* inttypes.h includes stdint.h */
Expand Down
2 changes: 2 additions & 0 deletions json_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef _json_object_h_
#define _json_object_h_

#include "json_inttypes.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

0 comments on commit b21b137

Please sign in to comment.