Visual Studio 2022 在 WSL2+CMake 开发环境下,出现头文件报错

查看 20|回复 0
作者:pk5ls20   
如标题,需要使用 Visual Studio 2022 通过 WSL2 进行 CMake 项目开发,WSL 为Ubuntu 22.04,在配置好后可以正常运行和调试,但是出现如下 IntelliSense 报错

报错的都是从 wsl 下自动复制过来的头文件:

该项目的CMakeSettings.json如下:
{
  "configurations": [
    {
      "name": "WSL-GCC-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeExecutable": "cmake",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "inheritEnvironments": [ "linux_x64" ],
      "wslPath": "${defaultWSLPath}",
      "intelliSenseMode": "linux-gcc-x64",
      "remoteCopyUseCompilerDefaults": true
    },
    {
      "name": "WSL-GCC-Release",
      "generator": "Ninja",
      "configurationType": "RelWithDebInfo",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeExecutable": "cmake",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "inheritEnvironments": [ "linux_x64" ],
      "wslPath": "${defaultWSLPath}",
      "variables": []
    }
  ]
}
折腾了一晚上在全网没找到合适的解决方案...求助各位万能的 V 友,为什么 IntelliSense 会出现头文件报错?如何解决?鄙人学艺不精,请求各位大佬指点
您需要登录后才可以回帖 登录 | 立即注册

返回顶部