diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d2faf19..e10acc20 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,14 +10,17 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Linux") stop() elseif(version LESS 7.1.0) set(CMAKE_CXX_STD_FLAGS c++14) + set(CXX_STD 14) MESSAGE(STATUS "c++14") else() set(CMAKE_CXX_STD_FLAGS c++17) + set(CXX_STD 17) MESSAGE(STATUS "c++17") endif() else() #MacOS use c++17 set(CMAKE_CXX_STD_FLAGS c++17) + set(CXX_STD 17) endif() include_directories(${PROJECT_SOURCE_DIR}/trantor ${PROJECT_SOURCE_DIR}/lib/inc ${PROJECT_SOURCE_DIR}/orm_lib/inc) @@ -131,7 +134,7 @@ SET(CONFIG_HEADER "${PROJECT_SOURCE_DIR}/config.h") file(WRITE "${CONFIG_HEADER}" "#pragma once\n") file(APPEND "${CONFIG_HEADER}" "#include \n") - +file(APPEND "${CONFIG_HEADER}" "#define CXX_STD " ${CXX_STD} "\n") if(USE_ORM) file(APPEND "${CONFIG_HEADER}" "#define USE_ORM 1\n") if(PostgreSQL_FOUND) diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index b149d7ee..a497ed73 100755 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -88,8 +88,11 @@ void HttpServer::onConnection(const TcpConnectionPtr &conn) { _disconnectWebsocketCallback(requestParser->webSocketConn()); } - //conn->getMutableContext()->reset(); reset() is in c++17 - conn->setContext(0); +#if (CXX_STD > 14) + conn->getMutableContext()->reset(); //reset(): since c++17 +#else + conn->getMutableContext()->clear(); +#endif } } _connectionCallback(conn);