fix: compatibility of C and C++

// fix: move .h to .c for cpp
// static IdGenerator *_idGenerator = NULL;
上级 b394f90e
......@@ -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
......@@ -34,5 +34,13 @@ typedef struct IdGenOptions {
} IdGeneratorOptions;
#ifdef __cplusplus
extern "C"
{
#endif
extern IdGeneratorOptions BuildIdGenOptions(uint32_t workerId);
#ifdef __cplusplus
}
#endif
......@@ -9,6 +9,8 @@
#include <unistd.h>
#include "IdGenerator.h"
static IdGenerator *_idGenerator = NULL;
static inline uint64_t WorkerM1Id()
{
return WorkerM1NextId(_idGenerator->Worker);
......
......@@ -21,10 +21,6 @@ typedef struct IdGenerator {
} IdGenerator;
static IdGenerator *_idGenerator = NULL;
extern IdGenerator *GetIdGenInstance();
extern void SetOptions(IdGeneratorOptions options);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册