
mac下Visual Studio Code (vscode) 配置C++开发
一、下载vscode https://code.visualstudio.com/#alt-downloads二、安装插件C/C++,C/C++ Clang Command Adapte三、新建first.cpp文件,写如下的代码#include <iostream>using namespace std;int main(){cout << "hello world" &
·
一、安装command line tool指令:
xcode-select --install
一、下载vscode Visual Studio Code - Code Editing. Redefined
二、
1、安装插件C/C++,code Runner codeLLDB
2、code Runner 里扩展设置
Clean previous output 打勾
Ignore selection 打勾
Previous focus 取消
Run in Terminal 打勾
Save All Files Before Run 打勾
Save File Before Run 打勾
三、新建first.cpp文件,写如下的代码
1)
#include <iostream>
using namespace std;
int main(){
cout << "hello world" << endl;
return 0;
}
如下图的这样
2) 配置tasks ,按 comand+shift+P ,输入task
C选择clang C++选择clang++
tasks代码如下
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ 生成活动文件",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: /usr/bin/clang++"
}
]
}
3)选择first.cpp,创建launch
把下图红框替换成 :${fileDirname}/${fileBasenameNoExtension} ,再改下这个:externalConsole:true
再最后加一行"preLaunchTask": "C/C++: clang++ 生成活动文件" ,加一行的内容就是tasks的lable冒号后的内容
launch.json如下
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ 生成活动文件"
}
]
}
四、如果调C语言的话,跟上面C++的类似
1)按 comand+shift+P ,输入task 选择clang 会多增加
更多推荐
所有评论(0)