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();