1
0
mirror of synced 2026-02-17 10:27:55 +08:00

fix: compatibility of C and C++

// fix: move .h to .c for cpp
// static IdGenerator *_idGenerator = NULL;
This commit is contained in:
AuroraTea
2023-01-23 17:35:48 +08:00
parent b394f90ed2
commit 2da2aa8b4b
4 changed files with 17 additions and 4 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,8 @@
#include <unistd.h>
#include "IdGenerator.h"
static IdGenerator *_idGenerator = NULL;
static inline uint64_t WorkerM1Id()
{
return WorkerM1NextId(_idGenerator->Worker);

View File

@@ -21,10 +21,6 @@ typedef struct IdGenerator {
} IdGenerator;
static IdGenerator *_idGenerator = NULL;
extern IdGenerator *GetIdGenInstance();
extern void SetOptions(IdGeneratorOptions options);