From 6a317a29f6a531532b0d4e3b490e962c95569a70 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Mon, 19 Feb 2024 15:10:31 +0530 Subject: [PATCH] fix: protect extern C under ifdef cplusplus --- cpp/negentropy_wrapper.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cpp/negentropy_wrapper.h b/cpp/negentropy_wrapper.h index 9ee90e6..8cc58d2 100644 --- a/cpp/negentropy_wrapper.h +++ b/cpp/negentropy_wrapper.h @@ -2,25 +2,30 @@ #ifndef _NEGENTROPY_WRAPPER_H #define _NEGENTROPY_WRAPPER_H +#ifdef __cplusplus +#define EXTERNC extern "C" +#else +#define EXTERNC +#endif //This is a C-wrapper for the C++ library that helps in integrating negentropy with nim code. //TODO: Do error handling by catching exceptions -extern "C" void* storage_new(const char* db_path, const char* name); +EXTERNC void* storage_new(const char* db_path, const char* name); -extern "C" void* negentropy_new(void* storage, uint64_t frameSizeLimit); +EXTERNC void* negentropy_new(void* storage, uint64_t frameSizeLimit); -extern "C" const char* negentropy_initiate(void* negentropy); +EXTERNC const char* negentropy_initiate(void* negentropy); -extern "C" void negentropy_setinitiator(void* negentropy); +EXTERNC void negentropy_setinitiator(void* negentropy); -extern "C" bool storage_insert(void* storage, uint64_t createdAt, const char* id); +EXTERNC bool storage_insert(void* storage, uint64_t createdAt, const char* id); -extern "C" bool storage_erase(void* storage, uint64_t createdAt, const char* id); +EXTERNC bool storage_erase(void* storage, uint64_t createdAt, const char* id); -extern "C" const char* reconcile(void* negentropy, const char* query); +EXTERNC const char* reconcile(void* negentropy, const char* query); -extern "C" const char* reconcile_with_ids(void* negentropy, const char* query, const char* have_ids[], +EXTERNC const char* reconcile_with_ids(void* negentropy, const char* query, const char* have_ids[], uint64_t have_ids_len, const char* need_ids[], uint64_t need_ids_len); #endif