Lately Intellisense in my VSC started giving me the above error in a working code. If I write:
#include <iostream>
#include <string>
int main (int argc, char **argv)
{
std::string str = "Hello";
for(auto c : str) {}
return 0;
}
then VSC highlights the for loop saying: "no != operator matches these operands".
I tried compiling the code outside VSC and it worked without any problems. I also tried downgrading the VSC's version, but the problem still persist. I suspect the problem may be in some external tool the VSC uses, but I have got no clue as of what it is.
I'm using the below configuration:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/src"
],
"defines": [
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++20",
"intelliSenseMode": "gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
EDIT:
More info:
- I've worked with C++20 for a long time in VSCode and I have never had such a problem before,
- The bug persists even when I purge the VSCode installation and put a fresh install of both VSC and a C/C++ extension (the one which provides Intellisense service in VSC)
- My VSC is in version 1.78 and the C/C++ extension is v1.16.0