
如标题,需要使用 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 会出现头文件报错?如何解决?鄙人学艺不精,请求各位大佬指点
1 labubu 2023-05-23 11:03:05 +08:00 源目录也设置一下? |
2 hez2010 2023-05-23 11:35:18 +08:00 能正常构建的话感觉可以无视,或者关掉 VS 后删除目录下的 .vs 隐藏文件夹来刷新一下 VS 的 cache 试试。 |
3 pk5ls20 OP @daimiaopeng 貌似**Visual Studio CMake**项目没有设置源目录的位置诶,找了半天没摘到 |
5 junmoxiao 2023-05-23 14:10:16 +08:00 vscode + xmake + clangd |
6 elechi 2023-05-23 14:11:18 +08:00 我在 windows 下开发都出现过,之后重装了 vs 才搞好。 |
8 hhjuteman 2023-05-23 17:17:49 +08:00 visual studio 对 cmake 目录的支持有的时候就是这样的,intellsense 抽风。 |
9 Jhon11 2023-06-27 17:26:35 +08:00 via iPhone Vs 的远程好像会把文件下到本地,包括系统的文件,你可以清除下缓存就可以了 |
10 daveh 2023-06-29 18:38:57 +08:00 via iPhone 换 CLion+WSL 1 ,Visual Studio 也落后了。 |