I'm using g++-9 and c++17 on Linux Mint 19.2. The compiler is literally telling me to include <memory>
adjacent to where I'm already including it:
/home/luke/workspace/crab/Src/Brain/EpisodicMemory.cpp:2:1: note: ‘std::make_unique’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
1 | #include "EpisodicMemory.h"
+++ |+#include <memory>
2 | #include <memory>
I can produce the error with this minimal example:
#include <memory>
int main(int argc, char** argv) {
std::unique_ptr<int> test = std::make_unique<int>(4);
return 0;
}
Really don't know what's going on.
Here is my CMakeLists.txt (since you don't believe I'm using c++17):
cmake_minimum_required(VERSION 3.10)
project(crab)
find_package(Qt5Widgets)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -g -fsanitize=address -std=c++17 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
include_directories(${Qt5Widgets_INCLUDE_DIRS})
#file(GLOB BRAIN_FILES Brain/*.cpp Brain/*.h)
#add_executable(crab ${BRAIN_FILES} main.cpp)
add_executable(crab main.cpp)
target_link_libraries(crab Qt5::Widgets)
I think linking Qt might be changing my compiler settings but I don't know why that would happen
我通过用set(CMAKE_CXX_STANDARD 17)替换-std = c ++ 17来修复它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.