首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Visual代码中包含C++20模块

如何在Visual代码中包含C++20模块
EN

Stack Overflow用户
提问于 2021-02-23 17:57:55
回答 1查看 3.3K关注 0票数 0

我正在用Visual代码编写C++20代码。我的配置如下所示:

文件c_cpp_properties.json

代码语言:javascript
复制
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/local/Cellar/gcc/10.2.0/bin/g++-10",
            "cStandard": "c11",
            "cppStandard": "c++20",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

文件tasks.json

代码语言:javascript
复制
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/local/Cellar/gcc/10.2.0/bin/g++-10",
            "args": [
                "-g",
                "-pthread",
                "-std=c++20",
                "-I/usr/local/Cellar/gcc/10.2.0/include",
                "-I/usr/local/Cellar/fmt/7.1.3/include",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ]
}

在我尝试使用syncstream之前,一切看起来都很好,这是在C++20中引入的。

当我运行#include <syncstream>时,编译器总是给出一个错误:

代码语言:javascript
复制
fatal error: syncstream: No such file or directory
    5 | #include <syncstream>
      |          ^~~~~~~~~~~~
compilation terminated.

如何在Visual代码中进行配置,以便编译器可以使用C++20模块?

EN

回答 1

Stack Overflow用户

发布于 2021-02-23 18:07:24

参见https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_library_features中的“同步缓冲的ostream”

您需要libstdc++11。您的编译器(g++10)还不支持syncstream

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66338566

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档