Hi,
Frequently when opening a cmake project in visual studio there’s a bug where intellisense cannot recognize some of the C++ standard libraries. I have found a workaround, if I intentionally break my CMakePresets.json file and then unbreak it and save it, the problem goes away.
This isn’t a very good practice though, so I’d like to find a proper solution. Here’s a look at my simple CMakePresets.json file:
{
"version": 3,
"configurePresets": [
{
"binaryDir": "build",
"generator": "Visual Studio 17 2022",
"name": "default"
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}
AFAIK the issue stems from there being some sort of difference between the compiler used in your cmake project, and the one used by intellisense to check your code. I believe there is a way to add a vendor field to your CMakePresets.json file and force intellisense to behave in a certain way that prevents this, but I don’t know how to do that (if that’s even the correct solution). I’m writing C++ and using C++ 20 standard. I might also add I’m using VS 2022.
I hope that makes sense, I’m still quite new to this and sometimes it feels very overwhelming 
Any insight at all into this would be most appreciated, thank you.
1 Like
I’ve never experienced this; can you make a reproducer?
I’ll need a bit of time to do that Richard, but I’ll have a go! Thanks.
Well, after spending the day trying to re-create the problem, now I can’t 
It seems it usually happens whenever I copy the project to another folder and re-generate. Whenever I do this I clear out the build folder, otherwise it complains that the CMakeCache file contains bad paths.
I’ve tried this however with a simple test project and it still isn’t reappearing. The next time I see it I’ll stop what I’m doing and upload the whole project to a OneDrive location you can download from and inspect if you like.
Sorry to not be able to give a clearer explanation but at this time I can’t 
Ok here is a version of the project that has the bug. It’s a simple(ish) SDL3 project and will certainly contain files not needed to examine the bug. However not wanting to accidentally remove the error I have simply included everything to be sure. It’s a 40MB download zip expanding to 120MB when uncompressed just for your information.
CMake project containing Intellisense error.
It only ever happens when copying files from an existing project into a new one, and then removing the Cache and rebuilding.
Thanks.
p.s. If you intentionally break the CMakePresets.json file (add an extra curly bracket } where it shouldn’t be) and then build, Visual Studio will default to a standard configuration. If you then un-break the CMakePresets.json file and rebuild it returns to normal with the error no longer present.