当我包含libevent.h时,我得到了一个非常特殊的错误。 它无法找到redisAsyncContext结构。 这是我的头文件
#include <hiredis/hiredis.h>
#include <hiredis/async.h>
#include <hiredis/adapters/libevent.h>
class RedisMgr :Thread{
public:
static RedisMgr *getRedisMgr ();
int Init();
void Start();
int End();
void* run();
int Publish(int type);
private:
static RedisMgr s_instance;
bool exitThread;
redis_t Pub_Redis;
sem_t redis_publock;
RedisMgr();
~RedisMgr ();
static void pubCallback(redisAsyncContext *c,void *r,void *privdata);
void pubCallback_Handler(redisAsyncContext *c,void *privdata);
static void connectCallback(const redisAsyncContext *c,int status);
void connectCallback_Handler(const redisAsyncContext *c,int status);
static void disconnectCallback(const redisAsyncContext *c,int status);
void disconnectCallback_Handler(const redisAsyncContext *c,int status);
};
从包含的文件libevent.h和我在.h中创建的refisAsyncContext引用均引发错误。
这是错误:
/usr/include/hiredis/adapters/libevent.h:11:5: error: 'redisAsyncContext' does not name a type
redisAsyncContext *context;
src/headers/RedisMgr.h:36:5: error: 'redisAsyncContext' does not name a type
redisAsyncContext *c;