Skip to content

Commit

Permalink
libjq: extern C for C++
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rockwotj authored Nov 28, 2023
1 parent 460a5c1 commit 6b82dd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/jq.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <stdio.h>
#include "jv.h"

#ifdef __cplusplus
extern "C" {
#endif

enum {
JQ_DEBUG_TRACE = 1,
JQ_DEBUG_TRACE_DETAIL = 2,
Expand Down Expand Up @@ -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 */
7 changes: 7 additions & 0 deletions src/jv.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <stdint.h>
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

#if (defined(__GNUC__) && __GNUC__ >= 7) || \
(defined(__clang__) && __clang_major__ >= 10)
# define JQ_FALLTHROUGH __attribute__((fallthrough))
Expand Down Expand Up @@ -260,6 +264,9 @@ int jv_cmp(jv, jv);
jv jv_group(jv, jv);
jv jv_sort(jv, jv);

#ifdef __cplusplus
}
#endif

#endif

Expand Down

0 comments on commit 6b82dd3

Please sign in to comment.