当前位置: 首页 > news >正文

Mac-VScode-C++环境配置

mac上自带了clang所以不是必须下载Homebrew

下面是配置文件(注释记得删一下)

package.json

{"name": "git-base","displayName": "%displayName%","description": "%description%","version": "1.0.0","publisher": "vscode","license": "MIT","engines": {"vscode": "0.10.x"},"categories": ["Other"],"main": "./dist/extension.js","browser": "./dist/browser/extension.js","icon": "resources/icons/git.png","capabilities": {"virtualWorkspaces": true,"untrustedWorkspaces": {"supported": true}},"contributes": {"commands": [{"command": "git-base.api.getRemoteSources","title": "%command.api.getRemoteSources%","category": "Git Base API"}],"menus": {"commandPalette": [{"command": "git-base.api.getRemoteSources","when": "false"}]},"languages": [{"id": "git-commit","aliases": ["Git Commit Message", "git-commit"],"filenames": ["COMMIT_EDITMSG", "MERGE_MSG"],"configuration": "./languages/git-commit.language-configuration.json"},{"id": "git-rebase","aliases": ["Git Rebase Message", "git-rebase"],"filenames": ["git-rebase-todo"],"filenamePatterns": ["**/rebase-merge/done"],"configuration": "./languages/git-rebase.language-configuration.json"},{"id": "ignore","aliases": ["Ignore", "ignore"],"extensions": [".gitignore_global", ".gitignore", ".git-blame-ignore-revs"],"configuration": "./languages/ignore.language-configuration.json"}],"grammars": [{"language": "git-commit","scopeName": "text.git-commit","path": "./syntaxes/git-commit.tmLanguage.json"},{"language": "git-rebase","scopeName": "text.git-rebase","path": "./syntaxes/git-rebase.tmLanguage.json"},{"language": "ignore","scopeName": "source.ignore","path": "./syntaxes/ignore.tmLanguage.json"}]},"repository": {"type": "git","url": "https://github.com/microsoft/vscode.git"}
}

c_cpp_propreties.json

{"configurations": [{"name": "Mac","includePath": ["${workspaceFolder}/**","/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"  // 指定 libc++ 路径],"defines": [],"compilerPath": "/usr/bin/clang++",  // 使用 clang++ 编译器"cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "macos-clang-arm64"}],"version": 4
}

settings.json

{"code-runner.executorMap": {"cpp": "cd $dir && clang++ -std=c++17 -stdlib=libc++ -Wall $fileName -o a.out && ./a.out"  // 使用 clang++ 编译器},"code-runner.runInTerminal": true,"files.autoSave": "afterDelay","terminal.integrated.defaultProfile.osx": "zsh","terminal.integrated.defaultEncoding": "utf-8","locale": "zh-cn","enable-crash-reporter": true,"crash-reporter-id": "3205589b-8611-4466-8315-38f465957f48"
}

其中 code-runner.runInTerminal设置为true解决了mac默认在输出跑无法输入的问题

tasks.json

{"version": "2.0.0","tasks": [{"label": "C/C++: clang++ 生成活动文件","type": "shell","command": "/usr/bin/clang++",  // 使用 clang++ 编译器"args": ["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"],"group": "build","problemMatcher": ["$gcc"  // 使用 $gcc 而不是 $clang],"detail": "生成 C++ 程序"},{"type": "cppbuild","label": "C/C++: clang++ 生成活动文件","command": "/usr/bin/clang++",  // 使用 clang++ 编译器"args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"  // 使用 $gcc 而不是 $clang],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}]
}

 C/C++编辑配置(UI)

 command+shift+p,输入C/C++编辑配置(UI)

编辑器路径:/usr/bin/clang++

IntelliSense 模式根据你的芯片选择是arm还是intell

c标准的话一般为17

相关文章:

  • Git拉分支技巧:从零开始创建并推送分支
  • 深入理解 CICD 与 Jenkins 流水线:从原理到实践
  • 基于Docker+k8s集群的web应用部署与监控
  • 【esp32 点亮led】-解决不能闪烁问题
  • 深入理解Linux中的线程控制:多线程编程的实战技巧
  • 常用算法解析:从基础排序到图论应用
  • 51单片机的原理图和PCB绘制
  • 常用的几种 Vue 父子组件传值方式
  • 使用 GitHub Actions 和 Nuitka 实现 Python 应用(customtkinter ui库)的自动化跨平台打包
  • 状态管理最佳实践:Bloc架构实践
  • Android Jetpack Compose 状态管理解析:remember vs mutableStateOf,有啥不一样?为啥要一起用?
  • HTML表单与数据验证设计
  • 区块链预言机(Oracle)详解:如何打通链上与现实世界的关键桥梁?
  • 如何将自己封装的组件发布到npm上:详细教程
  • JavaScript学习教程,从入门到精通,DOM节点操作语法知识点及案例详解(21)
  • Android学习总结之APK打包流程
  • 使用Ingress发布应用程序
  • swift-12-Error处理、关联类型、assert、泛型_
  • ospf实验
  • 【HDFS入门】HDFS性能调优实战:压缩与编码技术深度解析
  • 一年一CT,十年进ICU?关于CT检查致癌的真相
  • 十大券商看后市|A股下行波动风险有限,震荡中有望逐步抬升
  • 独家专访|苏童:《好天气》是一部献给中国郊区的作品
  • 青创上海—2025浦东徒步行活动举行,“青年草坪创新创业湃对”正式亮相
  • 外交部介绍中印尼“2+2”机制首次部长级会议将讨论的议题
  • 世卫成员国就《大流行病协议》达成一致,首次演练应对气候诱发的病毒危机