proxygen folly inconsistent types ‘int’ and ‘bool’ deduced for lambda return type

316 Views Asked by At

While creating a web server using proxygen, I included proxygen::HTTPServer in another subdirectory, and I get an error.

But I included the same library in another directory, but I can not get an error.

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 ( Error )

#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 ( Well Compile )

#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")
...

why occurs error?

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

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

Thank you for help.

0

There are 0 best solutions below