1
0
mirror of synced 2025-12-14 00:58:09 +08:00

fix: C++ 兼容性保护

This commit is contained in:
lymslive
2022-06-07 14:16:26 +08:00
parent 5e24340526
commit 24949581d9
4 changed files with 18 additions and 1 deletions

View File

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

View File

@@ -34,5 +34,13 @@ typedef struct IdGenOptions {
} IdGeneratorOptions;
#ifdef __cplusplus
extern "C"
{
#endif
extern IdGeneratorOptions BuildIdGenOptions(uint32_t workerId);
#ifdef __cplusplus
}
#endif

View File

@@ -9,6 +9,7 @@
#include <unistd.h>
#include "IdGenerator.h"
static IdGenerator *_idGenerator = NULL;
static inline uint64_t WorkerM1Id() {
return WorkerM1NextId(_idGenerator->Worker);

View File

@@ -22,7 +22,8 @@ typedef struct IdGenerator {
} IdGenerator;
static IdGenerator *_idGenerator = NULL;
// fix: move to cpp
// static IdGenerator *_idGenerator = NULL;
extern IdGenerator *GetIdGenInstance();