Intellisense not detecting standard libraries in Visual Studio

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 :frowning:

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.