Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add 'extern' statements to public headers for C++ compatibility #450

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cutils.h
Original file line number Diff line number Diff line change
@@ -32,6 +32,11 @@
#if defined(_WIN32)
#include <windows.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_MSC_VER)
#include <winsock2.h>
#include <malloc.h>
@@ -212,7 +217,7 @@ static inline int clz64(uint64_t a)
return clz32((unsigned)(a >> 32));
else
return clz32((unsigned)a) + 32;
#endif
#endif
#else
return __builtin_clzll(a);
#endif
@@ -527,4 +532,8 @@ int js_cond_timedwait(js_cond_t *cond, js_mutex_t *mutex, uint64_t timeout);

#endif /* !defined(EMSCRIPTEN) && !defined(__wasi__) */

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* CUTILS_H */
8 changes: 8 additions & 0 deletions libbf.h
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#if INTPTR_MAX >= INT64_MAX && !defined(_WIN32) && !defined(__TINYC__)
#define LIMB_LOG2_BITS 6
#else
@@ -532,4 +536,8 @@ static inline int bfdec_resize(bfdec_t *r, limb_t len)
}
int bfdec_normalize_and_round(bfdec_t *r, limb_t prec1, bf_flags_t flags);

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* LIBBF_H */
8 changes: 8 additions & 0 deletions libregexp.h
Original file line number Diff line number Diff line change
@@ -28,6 +28,10 @@

#include "libunicode.h"

#ifdef __cplusplus
extern "C" {
#endif

#define LRE_BOOL int /* for documentation purposes */

#define LRE_FLAG_GLOBAL (1 << 0)
@@ -84,4 +88,8 @@ static inline int lre_js_is_ident_next(int c)

#undef LRE_BOOL

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* LIBREGEXP_H */
8 changes: 8 additions & 0 deletions libunicode.h
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@
#include <stddef.h>
#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

#define LRE_BOOL int /* for documentation purposes */

#define LRE_CC_RES_LEN_MAX 3
@@ -115,4 +119,8 @@ int unicode_prop(CharRange *cr, const char *prop_name);

#undef LRE_BOOL

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* LIBUNICODE_H */
8 changes: 8 additions & 0 deletions list.h
Original file line number Diff line number Diff line change
@@ -28,6 +28,10 @@
#include <stddef.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct list_head {
struct list_head *prev;
struct list_head *next;
@@ -96,4 +100,8 @@ static inline int list_empty(struct list_head *el)
for(el = (head)->prev, el1 = el->prev; el != (head); \
el = el1, el1 = el->prev)

#ifdef __cplusplus
} /* extern "C" { */
#endif

#endif /* LIST_H */
Loading