簡體   English   中英

為什么 gcc10 看不到 -fcoroutines 標志?

[英]Why doesn't gcc10 see the -fcoroutines flag?

我正在嘗試使用包含在其中的#include <coroutine> header 文件編譯程序。 但是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

set(CMAKE_CXX_FLAGS "-pthread")

將標志設置為 -pthread 后,它不再具有以前具有協程標志的值。

PS 使用特定於目標的配置,即不要設置 CMAKE_CXX_FLAGS。 請改用 target_compile_options。 並使用 target_compile_features 而不是設置 CMAKE_CXX_STANDARD。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM