0

I get this error for my IntelliSense in VS Code:

cannot open source file "barrier" (dependency of "role_server.h") C/C++(1696)

I also have this issue for #include <experimental/coroutine>, but I believe this was included in the same C++ standard, so fixing the barrier should hopefully lead to the fix for "cannot open source file experimental/coroutine"

Barrier was included in c++ standard 20 and I configured c_cpp_properties.json to use that standard.

This is what the file currently looks like.

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/**",
                "/usr/local/include/**",
                "~/INSTALL/protobuf/src",
                "${workspaceFolder}"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c23",
            "cppStandard": "c++20",
            "intelliSenseMode": "linux-gcc-x86",
            "configurationProvider": "ms-vscode.makefile-tools",
            "compilerArgs": [
                "-std=c++20"
            ]
        }
    ],
    "version": 4
}

For reference, I use Bazelisk for building the executable and I don't run into any issues there, so it's just a VS Code configuration question.

Additionally, I have tried other strategies like changing my compilerPath and intelliSenseMode. I use Linux 20.04.1-Ubuntu.

starball
  • 20,030
  • 7
  • 43
  • 238
Ethan
  • 11
  • 2

1 Answers1

0

Seeing that you're on Ubuntu 20.04 (Focal Fossa), I'm assuming you just have the default GCC package? That one is for GCC 9.

If you look at https://en.cppreference.com/w/cpp/compiler_support, you'll see that std::barrier got added to GCC's standard library in version 11, clang's standard library in version 11, and MSVC's standard library in version 19.28.

Try installing the gcc-11 package. If you want to make gcc point to gcc-11, see also How to change the default GCC compiler in Ubuntu?.

starball
  • 20,030
  • 7
  • 43
  • 238