Skip to content

Build Error !! #721

@gggggwen

Description

@gggggwen

No direct indication of the source of the error which makes the bug fix so hard !!!!!

OS:CentOS 7 
  Cmake: 3.12.3 
  C++11

**当编译时出现如下报错 *

### 
`In file included from /usr/include/features.h:375:0,
                 from /usr/include/string.h:25,
                 from /usr/include/muduo/base/StringPiece.h:43,
                 from /usr/include/muduo/net/TcpConnection.h:15,
                 from /home/gwen/github_repo/chatings_server/include/server/chatservice.hpp:4,
                 from /home/gwen/github_repo/chatings_server/src/server/chatservice.cc:1:
/usr/include/assert.h:65:1: 错误:expected unqualified-id before string constant
 __BEGIN_DECLS
 ^

以下是chatservice.hh代码(但我想应该和下面代码关系不大, 报错信息并没有指明是哪一行出现错误):

`#ifndef CHATSERVICE_H
#define CHATSERVICE_H

#include <muduo/net/TcpConnection.h>
#include <unordered_map>
#include <functional>
using namespace std;
using namespace muduo;
using namespace muduo::net;

#include "json.hpp"
using json = nlohmann::json;

// 表示处理消息的事件回调方法类型
using MsgHandler = std::function<void(const TcpConnectionPtr &conn, json &js, Timestamp)>;

// 聊天服务器业务类
class ChatService
{
public:
    // 获取单例对象的接口函数
    static ChatService *get_instance();
    // 处理登录业务
    void login(const TcpConnectionPtr &conn, json &js, Timestamp time);
    // 处理注册业务
    void reg(const TcpConnectionPtr &conn, json &js, Timestamp time);
    // 获取消息对应的处理器
    MsgHandler getHandler(int msgid);

private:
    ChatService();

    // 存储消息id和其对应的业务处理方法
    std::unordered_map<int, MsgHandler> msgHandlerMap_;
  
};

#endif`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions