在Win10用最新版本的VS Code
Version: 1.94.2 (user setup)
Commit: 384ff7382de624fb94dbaf6da11977bba1ecd427
Date: 2024-10-09T16:08:44.566Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.19045
和mingw64 的gcc toolchain,
$ g++ --version
g++.exe (Rev3, Built by MSYS2 project) 14.1.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
在编译C/C++文件时报很多错误,首先intellisense这关就过不了,报错很多的class, container不认识,或者头文件找不到。按照VS Code github上提供的方法,是Microsoft 的 C/C++ extension的问题,在相应的extension github Repo 上提交issue,得到的回答是推荐我使用ucrt64 toolchain。我记得以前试过了,还是不行。
最后得到的解决方案是使用clang作为compiler,具体安装配置如下:
在MSYS2 MINGW64上运行
pacman -S mingw-w64-x86_64-clang
安装完后,运行:
$ clang --version
clang version 18.1.8
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/mingw64/bin
证明已经安装成功,安装目录为 C:/msys64/mingw64/bin, 实际上是你在安