From 6b82dd3c47c5eee8a7fcca063c683caafd5cdd9a Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Tue, 28 Nov 2023 15:50:25 -0600 Subject: [PATCH] libjq: extern C for C++ If using libjq from C++ it would be nice to not need to do this at the import site, so just extern "C" to the public headers for libjq Signed-off-by: Tyler Rockwood --- src/jq.h | 8 ++++++++ src/jv.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/jq.h b/src/jq.h index b44a6a5521..8e9a7b8cf8 100644 --- a/src/jq.h +++ b/src/jq.h @@ -4,6 +4,10 @@ #include #include "jv.h" +#ifdef __cplusplus +extern "C" { +#endif + enum { JQ_DEBUG_TRACE = 1, JQ_DEBUG_TRACE_DETAIL = 2, @@ -69,4 +73,8 @@ jv jq_util_input_get_current_line(jq_state*); int jq_set_colors(const char *); +#ifdef __cplusplus +} +#endif + #endif /* !JQ_H */ diff --git a/src/jv.h b/src/jv.h index 2cc63c79fb..083509ec26 100644 --- a/src/jv.h +++ b/src/jv.h @@ -5,6 +5,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #if (defined(__GNUC__) && __GNUC__ >= 7) || \ (defined(__clang__) && __clang_major__ >= 10) # define JQ_FALLTHROUGH __attribute__((fallthrough)) @@ -260,6 +264,9 @@ int jv_cmp(jv, jv); jv jv_group(jv, jv); jv jv_sort(jv, jv); +#ifdef __cplusplus +} +#endif #endif