当前位置: 首页 > 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

http://www.xdnf.cn/news/42841.html

相关文章:

  • 如何在 Go 中创建和部署 AWS Lambda 函数
  • 【linux基本工具的使用 yum vim gdb 以及makefile自动化构建项目】
  • 学习笔记十九——Rust多态
  • MFC文件-写MP4
  • Python打包程序为exe文件(py2exe)
  • AES (高级加密标准)
  • (mac)Grafana监控系统之监控Linux的Redis
  • 基于Matlab求解矩阵电容等效容值
  • 解决vscode找不到Python自定义模块,报错No module named ‘xxx‘
  • MySQL数据库(基础篇)
  • Gitlab runner 安装和注册
  • 解决模拟器打开小红书设备异常问题
  • n8n 中文系列教程_04.半开放节点深度解析:Code与HTTP Request高阶用法指南
  • 2025年渗透测试面试题总结-拷打题库08(题目+回答)
  • Docker Compose 外部网络(`external: true`)与内部网络的区别
  • 【AI图像创作变现】02工具推荐与差异化对比
  • 用于手部康复设备的TinyML语音分类嵌入式人工智能模块
  • 大模型day4 - LangChain
  • Jsp技术入门指南【九】详细讲解JSTL
  • Linux 文件系统目录结构详解
  • UID和GID的区别
  • optool为macho文件增加动态库
  • React+TS编写轮播图
  • FreeSWITCH 简单图形化界面41 - 批量SIP视频呼叫测试
  • 游戏引擎学习第237天:使用 OpenGL 显示图像
  • 绝对路径与相对路径
  • 【C++】多态 - 从虚函数到动态绑定的核心原理
  • HTTP:十.cookie机制
  • Kotlin实现Android应用保活方案
  • 基于maven-jar-plugin打造一款自动识别主类的maven打包插件