赞
踩
原文出自VScode C++环境配置 (MAC) - 知乎,本文只根据自己的实际诉求进行摘抄
其他参考视频:
Mac用Visual Studio Code编写C/C++ 苹果电脑VS Code快速编写C/C++教程_哔哩哔哩_bilibili
Macbook Pro 安装vscode并配置c/c++环境
官网下载 Visual Studio Code - Code Editing. Redefined
- #include<iostream>
- #include<string>
- #include<vector>
- using namespace std;
-
- int main(){
- int b = 1;
- // auto a = b;
- // cout << a << endl;
- // vector<string> msg{"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
- // int len = msg.size();
- // cout << "长度" << len << endl;
- for (int i=0; i<5; i++){
- // ms.push_back("a");
- cout << i << endl;
- }
-
- return 0;
- }
- {
- // 使用 IntelliSense 了解相关属性。
- // 悬停以查看现有属性的描述。
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "type": "lldb",
- "request": "launch",
- "name": "C++ debug",
- "program": "${fileDirname}/${fileBasenameNoExtension}",
- "args": [],
- "cwd": "${workspaceFolder}",
- "preLaunchTask": "C/C++: g++ 生成活动文件"
- }
- ]
- }
- {
- "tasks": [
- {
- "type": "cppbuild",
- "label": "C/C++: g++ 生成活动文件",
- "command": "/usr/bin/g++",
- "args": [
- "-std=c++17",
- "-stdlib=libc++",
- "-fdiagnostics-color=always",
- "-g",
- "-Wall",
- "${file}",
- "-o",
- "${fileDirname}/${fileBasenameNoExtension}"
- ],
- "options": {
- "cwd": "${fileDirname}"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": {
- "kind": "build",
- "isDefault": true
- },
- "detail": "调试器生成的任务。"
- }
- ],
- "version": "2.0.0"
- }
- {
- "configurations": [
- {
- "name": "Mac",
- "includePath": [
- "${workspaceFolder}/**"
- ],
- "defines": [],
- "macFrameworkPath": [
- "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
- ],
- "compilerPath": "/usr/bin/clang",
- "cStandard": "c11",
- "cppStandard": "c++17",
- "intelliSenseMode": "macos-clang-x64"
- }
- ],
- "version": 4
- }
- {
- // 使用 IntelliSense 了解相关属性。
- // 悬停以查看现有属性的描述。
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "type": "cppdbg",
- "request": "launch",
- "name": "Debug",
- "program": "${workspaceFolder}/opencv_test",
- "args": [],
- "cwd": "${workspaceFolder}",
- "preLaunchTask": "Makefile生成可执行文件"
- }
- ]
- }
- {
- "tasks": [
- {
- "type": "shell",
- "label": "Makefile生成可执行文件",
- "command": "make",
- "args": [
- "all",
- ],
- "options": {
- "cwd": "${workspaceFolder}"
- },
- "problemMatcher": [
- "$gcc"
- ],
- "group": {
- "kind": "build",
- "isDefault": true
- },
- "detail": "调试器生成的任务。"
- }
- ],
- "version": "2.0.0"
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。