From 24949581d92bbbfc972d15ee7d7660803f465263 Mon Sep 17 00:00:00 2001 From: lymslive <403708621@qq.com> Date: Tue, 7 Jun 2022 14:16:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20C++=20=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- C/source/YitIdHelper.h | 7 +++++++ C/source/idgen/IdGenOptions.h | 8 ++++++++ C/source/idgen/IdGenerator.c | 1 + C/source/idgen/IdGenerator.h | 3 ++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/C/source/YitIdHelper.h b/C/source/YitIdHelper.h index ef3f45b..723f2ab 100644 --- a/C/source/YitIdHelper.h +++ b/C/source/YitIdHelper.h @@ -7,6 +7,10 @@ #include "idgen/IdGenOptions.h" #include "idgen/common.h" +#ifdef __cplusplus +extern "C" +{ +#endif TAP_DLLEXPORT extern void TAP_STDCALL SetIdGenerator(IdGeneratorOptions options); @@ -17,3 +21,6 @@ extern void TAP_STDCALL SetWorkerId(uint32_t workerId); TAP_DLLEXPORT extern int64_t TAP_STDCALL NextId(); +#ifdef __cplusplus +} +#endif diff --git a/C/source/idgen/IdGenOptions.h b/C/source/idgen/IdGenOptions.h index deedafc..5d8cb74 100644 --- a/C/source/idgen/IdGenOptions.h +++ b/C/source/idgen/IdGenOptions.h @@ -34,5 +34,13 @@ typedef struct IdGenOptions { } IdGeneratorOptions; +#ifdef __cplusplus +extern "C" +{ +#endif + extern IdGeneratorOptions BuildIdGenOptions(uint32_t workerId); +#ifdef __cplusplus +} +#endif diff --git a/C/source/idgen/IdGenerator.c b/C/source/idgen/IdGenerator.c index b498371..c953136 100644 --- a/C/source/idgen/IdGenerator.c +++ b/C/source/idgen/IdGenerator.c @@ -9,6 +9,7 @@ #include #include "IdGenerator.h" +static IdGenerator *_idGenerator = NULL; static inline uint64_t WorkerM1Id() { return WorkerM1NextId(_idGenerator->Worker); diff --git a/C/source/idgen/IdGenerator.h b/C/source/idgen/IdGenerator.h index f9841b7..1f382c0 100644 --- a/C/source/idgen/IdGenerator.h +++ b/C/source/idgen/IdGenerator.h @@ -22,7 +22,8 @@ typedef struct IdGenerator { } IdGenerator; -static IdGenerator *_idGenerator = NULL; +// fix: move to cpp +// static IdGenerator *_idGenerator = NULL; extern IdGenerator *GetIdGenInstance();