proxygen愚蠢的为lambda返回类型推导了不一致的类型“ int”和“ bool”

时间:2018-08-20 18:13:54

标签: c++ cmake folly proxygen

使用proxygen创建Web服务器时,我在另一个子目录中包含了proxygen::HTTPServer,但出现错误。

但是 我在另一个目录中包含了相同的库,但没有收到错误。

In file included from /usr/local/include/folly/FBString.h:60:0,
                 from /usr/local/include/folly/Demangle.h:19,
                 from /usr/local/include/folly/Conv.h:40,
                 from /usr/local/include/folly/String.h:27,
                 from /usr/local/include/folly/io/async/SSLContext.h:35,
                 from /usr/local/include/wangle/ssl/SSLContextConfig.h:19,
                 from /usr/local/include/proxygen/httpserver/HTTPServer.h:12,
                 from /home/skyend/ds/sentencer-backend-engine/include/router/src/Router.h:9,
                 from /home/skyend/ds/sentencer-backend-engine/include/router/src/Router.cpp:5:
/usr/local/include/folly/memory/Malloc.h: In lambda function:
/usr/local/include/folly/memory/Malloc.h:196:38: error: inconsistent types ‘int’ and ‘bool’ deduced for lambda return type
     return (origAllocated != *counter);

include / router / CMakeListx.txt

add_library(sbx_router src/Router.cpp src/Router.h)
target_link_libraries(sbx_router r3 folly)

include / router / src / Router.h(错误)

#include <iostream>
#include <router/src/r3.h>
#include <proxygen/httpserver/HTTPServer.h>
#include <proxygen/httpserver/RequestHandlerFactory.h>

src / http / service / CMakeLists.txt

add_library(sbx_services 
        LoggingHandlerFactory.h)

src / http / service / LoggingHandlerFactory.h(编译正确)

#include "libs/stringUtils.h"
#include <proxygen/httpserver/HTTPServer.h>
#include <proxygen/httpserver/RequestHandlerFactory.h>
#include <boost/algorithm/string.hpp>
#include <vector>

namespace sbx::http::service {
    class LoggingHandlerFactory : public proxygen::RequestHandlerFactory {
    public:
        void onServerStart(folly::EventBase * /*evb*/) noexcept override {}

        void onServerStop() noexcept override {}

        proxygen::RequestHandler *onRequest(proxygen::RequestHandler * nextHandler, proxygen::HTTPMessage * msg) noexcept override {

            std::string method = "unknown";
            if( msg->getMethod().hasValue() ) {
                method = proxygen::methodToString(msg->getMethod().value());
            }

            std::cout << "[" << method << "] " << msg->getPath() << std::endl;

            if( nextHandler != nullptr ){
                return nextHandler;
            }
        }
    };
}

CMakeLists.txt

...
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

# Things to always src as flags. Change as needed.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")

# Build-type specific flags. Change as needed.
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
...

为什么会发生错误?

router.h:9 #include <proxygen/httpserver/HTTPServer.h>

Router.cpp:5 #include <proxygen/httpserver/HTTPServer.h>

谢谢您的帮助。

0 个答案:

没有答案