VSCode中MinGW\bin路径解析失败问题求助
问题描述:
之前我的C/C程序在VSCode里运行完全正常,后来为了做Python项目安装了Anaconda Navigator,还把VSCode的解释器切换到了conda环境。等Python项目完成后我卸载了Anaconda,切回C开发,结果现在每次打开VSCode,终端里都会弹出一堆路径解析错误的提示,具体日志如下:
[9/30/2023, 3:58:27 PM] "C:\MinGW\bin" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'BOOMING BULLS' will be used instead.
[9/30/2023, 3:58:28 PM] For C++ source files, IntelliSenseMode was changed from "windows-msvc-x64" to "windows-gcc-x86" based on compiler args and querying compilerPath: "C:\MinGW\bin\gcc.exe"
[9/30/2023, 3:58:28 PM] IntelliSenseMode was changed because it didn't match the detected compiler. Consider setting "compilerPath" instead. Set "compilerPath" to "" to disable detection of system includes and defines.
[9/30/2023, 3:58:28 PM] For C source files, IntelliSenseMode was changed from "windows-msvc-x64" to "windows-gcc-x86" and cStandard was changed from "gnu17" to "gnu11" based on compiler args and querying compilerPath: "C:\MinGW\bin\gcc.exe"
[9/30/2023, 3:58:28 PM] IntelliSenseMode was changed because it didn't match the detected compiler. Consider setting "compilerPath" instead. Set "compilerPath" to "" to disable detection of system includes and defines.
[9/30/2023, 3:58:28 PM] "C:\MinGW\bin" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'ARRAYS' will be used instead.
[9/30/2023, 3:58:29 PM] "C:\MinGW\bin" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'ARRAYS' will be used instead.
[9/30/2023, 3:58:39 PM] "C:\MinGW\bin" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'ARRAYS' will be used instead.
[9/30/2023, 3:58:40 PM] "C:\MinGW\bin" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'ARRAYS' will be used instead.
我已经确认所有C/C++相关的扩展都已经安装好了,但还是会出现这些错误,有没有大佬能帮忙解决一下?
解决方案:
根据你的情况,大概率是Anaconda卸载过程中影响了系统环境变量或者VSCode的C/C++扩展配置,试试下面这几个办法:
检查并修复系统环境变量:
卸载Anaconda时可能误删了MinGW的Path路径。右键「此电脑」→「属性」→「高级系统设置」→「环境变量」,在「系统变量」里找到Path,查看是否包含C:\MinGW\bin。如果没有,点击「新建」添加这个路径,然后重启VSCode再试。手动配置c_cpp_properties.json:
打开VSCode的命令面板(快捷键Ctrl+Shift+P),输入C/C++: Edit Configurations (JSON)打开配置文件,做以下调整:- 确保
compilerPath字段设置为正确的gcc路径:"C:\\MinGW\\bin\\gcc.exe"(注意Windows路径需要用双反斜杠转义) - 检查
includePath是否包含MinGW的头文件目录,比如添加"C:\\MinGW\\include\\**",这样VSCode能正确识别头文件路径
保存配置后,重启VSCode生效。
- 确保
重置C/C++扩展的编译器路径设置:
打开VSCode设置(快捷键Ctrl+,),搜索C_Cpp: Compiler Path,手动输入C:\MinGW\bin\gcc.exe,然后关闭并重新打开VSCode,让扩展重新加载配置。清理VSCode缓存:
关闭VSCode,找到用户目录下的.vscode文件夹(一般在C:\Users\你的用户名\.vscode),删除里面的workspaceStorage等缓存文件夹,然后重新打开VSCode,让它重新检测编译器环境。
备注:内容来源于stack exchange,提问作者DILSHAD ALAM




