错误:“redisasynccontext”未命名类型redisasynccontext*context;

mzillmmw  于 2021-06-10  发布在  Redis
关注(0)|答案(1)|浏览(477)

当我包含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 *r, 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;
iovurdzv

iovurdzv1#

我发现了问题。不知何故,async.h被替换/更改,它不再具有redisasynccontext结构的定义。我从网上下载了相应的文件,构建工作正常。我应该在发帖前彻底检查一下-我的错

相关问题