Skip to content

Commit af084de

Browse files
andrjohnschqrlie
authored andcommitted
Add 'extern' statements to public headers for C++ compatibility
1 parent f9d1029 commit af084de

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

cutils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include <string.h>
3030
#include <inttypes.h>
3131

32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
3236
#if defined(_WIN32)
3337
#include <windows.h>
3438
#endif
@@ -212,7 +216,7 @@ static inline int clz64(uint64_t a)
212216
return clz32((unsigned)(a >> 32));
213217
else
214218
return clz32((unsigned)a) + 32;
215-
#endif
219+
#endif
216220
#else
217221
return __builtin_clzll(a);
218222
#endif
@@ -527,4 +531,8 @@ int js_cond_timedwait(js_cond_t *cond, js_mutex_t *mutex, uint64_t timeout);
527531

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

534+
#ifdef __cplusplus
535+
} /* extern "C" { */
536+
#endif
537+
530538
#endif /* CUTILS_H */

libbf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include <stddef.h>
2828
#include <stdint.h>
2929

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3034
#if INTPTR_MAX >= INT64_MAX && !defined(_WIN32) && !defined(__TINYC__)
3135
#define LIMB_LOG2_BITS 6
3236
#else
@@ -532,4 +536,8 @@ static inline int bfdec_resize(bfdec_t *r, limb_t len)
532536
}
533537
int bfdec_normalize_and_round(bfdec_t *r, limb_t prec1, bf_flags_t flags);
534538

539+
#ifdef __cplusplus
540+
} /* extern "C" { */
541+
#endif
542+
535543
#endif /* LIBBF_H */

libregexp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
#include "libunicode.h"
3030

31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
3135
#define LRE_BOOL int /* for documentation purposes */
3236

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

8589
#undef LRE_BOOL
8690

91+
#ifdef __cplusplus
92+
} /* extern "C" { */
93+
#endif
94+
8795
#endif /* LIBREGEXP_H */

libunicode.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include <stddef.h>
2828
#include <inttypes.h>
2929

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3034
#define LRE_BOOL int /* for documentation purposes */
3135

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

116120
#undef LRE_BOOL
117121

122+
#ifdef __cplusplus
123+
} /* extern "C" { */
124+
#endif
125+
118126
#endif /* LIBUNICODE_H */

list.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include <stddef.h>
2929
#endif
3030

31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
3135
struct list_head {
3236
struct list_head *prev;
3337
struct list_head *next;
@@ -96,4 +100,8 @@ static inline int list_empty(struct list_head *el)
96100
for(el = (head)->prev, el1 = el->prev; el != (head); \
97101
el = el1, el1 = el->prev)
98102

103+
#ifdef __cplusplus
104+
} /* extern "C" { */
105+
#endif
106+
99107
#endif /* LIST_H */

0 commit comments

Comments
 (0)