我正在尝试编译一个包含#include <coroutine>头文件的程序。但是gcc10抛出了一个错误
/usr/include/c++/10/coroutine:295:2: error: #error "the coroutine header requires -fcoroutines"
295 | #error "the coroutine header requires -fcoroutines"我在cmake中设置了所有必要的标志
cmake_minimum_required(VERSION 3.17)
project(cortest1)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "-fcoroutines")
set(CMAKE_CXX_FLAGS "-pthread")
add_executable(cortest1 main.cpp)但是编译器看不到-fcoroutines标志。我使用的是g ++ 10.2.0
发布于 2021-01-03 00:00:00
set(CMAKE_CXX_FLAGS "-pthread")将标志设置为-pthread后,它将不再具有具有协程标志的先前值。
附注:使用目标特定配置,即不设置CMAKE_CXX_FLAGS。请改用target_compile_options。并且使用target_compile_features而不是设置CMAKE_CXX_STANDARD。
https://stackoverflow.com/questions/65540415
复制相似问题