visual-studio-codec++20linter

How to configure linter for VSCode with format C++20


I'm using VS Code 1.78.2 with C/C++ extensions on Windows 10 and use MinGW64 for compiling so:

$> g++ --version
g++ (x86_64-win32-seh-rev1, Built by MinGW-Builds project) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.

I'm using <format> and added -std=c++20 to my compilation flags and my code is working fine.

But when I'm in the editor, it's keep showing me an error. It's probably my linter that I misconfigured but after some research on the internet and some tests i didn't find what is wrong

Error Image

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win64",
            "includePath": [
                "${workspaceFolder}\\include\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:\\mingw64\\bin\\g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++20",
            "intelliSenseMode": "windows-gcc-x64",
            "configurationProvider": "ms-vscode.makefile-tools"
        }
    ],
    "version": 4
}

I don't know where to search now, my question is :
How to configure my C/C++ extension to get my linter properly works with the format header ?

Do you have met this problem ? do you have any advice ?


Solution

  • Finally, I found a solution but behind the answer there is logic.

    While continuing my project, I encountered other header inclusion problems that were sometimes detected, sometimes not by the intellisense. A random behavior of my C/C++ extension on VS Code which was wasting a lot of my time..

    As I said before, I was using MinGW64 and my C/C++ extension uses its compiler for intellisense. But MinGW is an adaptation of the GNU tools which are designed to work on a Linux system with probably some specific headers for that.

    However, Windows has its own standard compilation tools: Microsoft Visual C++ (MSVC) with 'cl' which have been designed in the same way to work easily with the latest versions of Windows and therefore the headers of MSVC should work better than those of GNU for a Windows system.

    So I installed MSVC by following this tutorial: https://code.visualstudio.com/docs/cpp/config-msvc

    Then I re-configured my C/C++ extension to use MSVC and magic, the intellisense works perfectly well, even with the header format