Use inline const for urpc handle

This commit is contained in:
ZPaC 2023-01-31 10:23:33 +08:00
parent c1936efa2d
commit e9dbf2a7c8
1 changed files with 2 additions and 2 deletions

View File

@ -37,13 +37,13 @@ inline void *LoadURPC() {
} }
return urpc_handle; return urpc_handle;
} }
static void *kURPCHandle = LoadURPC(); inline const void *kURPCHandle = LoadURPC();
#define REG_URPC_METHOD(name, return_type, ...) \ #define REG_URPC_METHOD(name, return_type, ...) \
constexpr const char *k##name##Name = #name; \ constexpr const char *k##name##Name = #name; \
using name##FunObj = std::function<return_type(__VA_ARGS__)>; \ using name##FunObj = std::function<return_type(__VA_ARGS__)>; \
using name##FunPtr = return_type (*)(__VA_ARGS__); \ using name##FunPtr = return_type (*)(__VA_ARGS__); \
const name##FunPtr name##_func = DlsymFuncObj(name, kURPCHandle); const name##FunPtr name##_func = DlsymFuncObj(name, const_cast<void *> kURPCHandle);
// The symbols of liburpc.so to be dynamically loaded. // The symbols of liburpc.so to be dynamically loaded.
REG_URPC_METHOD(urpc_init, int, struct urpc_config *) REG_URPC_METHOD(urpc_init, int, struct urpc_config *)