准备工作:
安装好vscode
安装插件『C/C++』
正式开始:
首先是创建一个空的文件夹(比如文件夹为test),然后在其中新建一个.cpp文件(比如文件为hello.cpp)打开vscode打开test文件夹作为工作目录,接下来用三步配置好C++开发环境
第一步:
[⇧⌘P]打开命令模式,选择[C/Cpp: Edit Configurations(JSON)]命令,回车后会自动生成一个.vscode目录,目录下有一个c_cpp_properties.json文件,下面给出我的文件示例:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Library/Developer/CommandLineTools/usr/include/c++/v1",
"/usr/local/include",
"/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include",
"/Library/Developer/CommandLineTools/usr/include"
],
"defines": [],
"macFrameworkPath&