【发布时间】:2021-04-08 22:22:04
【问题描述】:
我正在尝试编译一个包含#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
【问题讨论】:
-
使用
make VERBOSE=1查看实际命令;这看起来像一个 cmake 配置错误 -
set设置。它不附加。