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

This commit is contained in:
Andrew Johnson 2024-07-01 13:30:20 +03:00 committed by Charlie Gordon
parent f9d1029ea3
commit af084de6f9
5 changed files with 41 additions and 1 deletions

View file

@ -29,6 +29,10 @@
#include <string.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32)
#include <windows.h>
#endif
@ -212,7 +216,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 +531,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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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
list.h
View file

@ -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 */