VSCode for mac 配置(c++)

目录

提前准备

配置

c_cpp_properties.json

task.json

settings.json

launch.json

注:

提前准备

        !!!注意!

        1.提前准备插件:自行百度     

        2.下载vs code 

Download Visual Studio Code - Mac, Linux, Windowshttps://code.visualstudio.com/Download

配置

新建一个文件夹,名字随意

打开vscode,写一个文件

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1005
#define N 500005
#define debug(...) cout << '[' << 'D' << 'E' << ']' << __LINE__ << ':' << __VA_ARGS__ << endl;
#define v(x) #x << '(' << x << ')'
#define mod 998244353
#define who(s,limit,tpe) s + tpe , s + limit + tpe
#define all(s) s.begin(),s.end()
#define s_(s) s.size()
int a[N];
string s;
int main(){
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cout << n + 1 << endl ;
}

命名为a.cpp

存在你新建的文件夹里 : command + s,以后保存编辑的时候也要用

command + shift + p:

c_cpp_properties.json

选择最后一个

新建一个c_cpp_properties.json,把里面的代码改成

{
    "configurations": [
      {
        "name": "Mac",
        "defines": [],
        "macFrameworkPath": [
          "/System/Library/Frameworks",
          "/Library/Frameworks",
          "${workspaceFolder}/**"
        ],
        "compilerPath": "/usr/bin/g++",
        "cStandard": "c11",
        "cppStandard": "c++14",
        "intelliSenseMode": "clang-x64",
        "browse": {
          "path": [
            "${workspaceFolder}"
          ],
          "limitSymbolsToIncludedHeaders": true,
          "databaseFilename": ""
        }
      }
    ],
    "version": 4
  }

task.json

command + shift + p, 输入task,

选择第一个

选择“C/C++: cpp 生成活动文件”

插入如下一段:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                "/property:GenerateFullPaths=true",
                "/t:build",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ 生成活动文件",
            "command": "/usr/bin/clang++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/clang++"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: cpp 生成活动文件",
            "command": "/usr/bin/cpp",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/cpp"
        }
    ]
}

settings.json

command + shift + p ,输入settings

 把里面的代码改成:

{
  "python.pythonPath": "/Users/zjx/anaconda3/bin/python3",
  "code-runner.executorMap": {
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
  },
  "editor.renderWhitespace": "all",
  "editor.renderLineHighlight": "all",
  "editor.formatOnSave": true,
  "code-runner.runInTerminal": true,
  "code-runner.ignoreSelection": true,
  "code-runner.enableAppInsights": false,
  "C_Cpp.updateChannel": "Insiders",
  "[makefile]": {
    "editor.insertSpaces": true
  },
  "C_Cpp.default.includePath": [
    "/usr/local/opt/opencv@3/include"
    // "/usr/local/Cellar/opencv/4.0.1/include/opencv4"
    // "/usr/local/include/opencv4"
  ],
  "files.associations": {
    "iosfwd": "cpp",
    "iostream": "cpp",
    "ostream": "cpp",
    "random": "cpp"
  },
  "C_Cpp.errorSquiggles": "Disabled"
}

launch.json

 点击后,选择(LLDB 和 c++有关的):

把里面的代码改成:

{
  // 
  // 使用 IntelliSense 了解相关属性。 
  // 悬停以查看现有属性的描述。
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}.out",
      "args": [],
      "cwd": "${workspaceFolder}",
      "stopAtEntry": true, // if true then stop at the main entry (function)
      "environment": [],
      "externalConsole": true,
      "MIMode": "lldb",
      "preLaunchTask": "build hello world"
    }
  ]
}

写完之后就结束了

返回你刚刚写的代码 

按下F5,

等编辑完之后

再按右上角的小三角,就OK了.

输入输出代码:

注:

        想放大要按command + “+”

        没下载好c++的人要提前下载xcode

        地址:xcode13正式版-Xcode 13 for Mac(开发工具) v13.3正式版 - 未来Mac下载

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值