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

vscode c++编译环境配置

几个重要配置文件

c_cpp_properties.json

{
    "configurations": [
      {
        "name": "Win64",
        "includePath": ["${workspaceFolder}/**"],
        "defines": ["_DEBUG", "UNICODE", "_UNICODE"],
        "windowsSdkVersion": "10.0.18362.0",
        "compilerPath": "C:/MinGW/bin/g++.exe",
        "cStandard": "c17",
        "cppStandard": "c++17",
        "intelliSenseMode": "gcc-x64"
      }
    ],
    "version": 4
  }

launch.json

{
  "configurations": [
  {
    "name": "(Windows) 启动",
    "type": "cppvsdbg",
    "request": "launch",
    "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${fileDirname}",
    "environment": [],
    
    //"console": "externalTerminal",
    "console": "integratedTerminal",//在内置终端运行
    "preLaunchTask": "g++"
  }
  ]
}

settings.json

{
    "files.associations": {
      "*.py": "python",
      "iostream": "cpp",
      "*.tcc": "cpp",
      "string": "cpp",
      "unordered_map": "cpp",
      "vector": "cpp",
      "ostream": "cpp",
      "new": "cpp",
      "typeinfo": "cpp",
      "deque": "cpp",
      "initializer_list": "cpp",
      "iosfwd": "cpp",
      "fstream": "cpp",
      "sstream": "cpp",
      "map": "c",
      "stdio.h": "c",
      "algorithm": "cpp",
      "atomic": "cpp",
      "bit": "cpp",
      "cctype": "cpp",
      "clocale": "cpp",
      "cmath": "cpp",
      "compare": "cpp",
      "concepts": "cpp",
      "cstddef": "cpp",
      "cstdint": "cpp",
      "cstdio": "cpp",
      "cstdlib": "cpp",
      "cstring": "cpp",
      "ctime": "cpp",
      "cwchar": "cpp",
      "exception": "cpp",
      "ios": "cpp",
      "istream": "cpp",
      "iterator": "cpp",
      "limits": "cpp",
      "memory": "cpp",
      "random": "cpp",
      "set": "cpp",
      "stack": "cpp",
      "stdexcept": "cpp",
      "streambuf": "cpp",
      "system_error": "cpp",
      "tuple": "cpp",
      "type_traits": "cpp",
      "utility": "cpp",
      "xfacet": "cpp",
      "xiosbase": "cpp",
      "xlocale": "cpp",
      "xlocinfo": "cpp",
      "xlocnum": "cpp",
      "xmemory": "cpp",
      "xstddef": "cpp",
      "xstring": "cpp",
      "xtr1common": "cpp",
      "xtree": "cpp",
      "xutility": "cpp",
      "stdlib.h": "c",
      "string.h": "c"
    },
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "aiXcoder.showTrayIcon": true
  }

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "g++",//label是编译任务名,后面配置启动任务的时候会通过调用label来调用对应的编译任务
            "command": "g++",
            "args": [//args中的内容是编译命令,可以添加一些内容
                //这个命令的作用是转化成GBK编码,可以防止终端中出现乱码
                //"-fexec-charset=GBK",
                "-g",
                "${file}",//如果要多文件编译,改成"${fileDirname\\*.c*}",可以把c和cpp文件都作为cpp文件编译。
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe"//控制生成文件的位置
                //这里增加一个build,让编译后的程序在同目录下的build文件夹中
                //"${fileDirname}/build/${fileBasenameNoExtension}.exe"
            ],
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "group": "build"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "C:/MinGW/bin/g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:/MinGW/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "编译器: C:/MinGW/bin/g++.exe"
        }
    ]
  }


http://www.kler.cn/a/314057.html

相关文章:

  • sql server 查看io资源使用
  • JS 实现SSE通讯和了解SSE通讯
  • jmeter常用配置元件介绍总结之后置处理器
  • DNS面临的4大类共计11小类安全风险及防御措施
  • 计算机毕业设计Python+Neo4j知识图谱医疗问答系统 大模型 机器学习 深度学习 人工智能 大数据毕业设计 Python爬虫 Python毕业设计
  • 浅谈C#之内存管理
  • 【数据结构与算法 | 灵神题单 | 二叉搜索树篇】力扣99, 1305, 230, 897
  • 在线免费公共DNS解析服务器列表
  • 计算机毕业设计 基于Python的校园个人闲置物品换购平台 闲置物品交易平台 Python+Django+Vue 前后端分离 附源码 讲解 文档
  • 信息安全数学基础(19)同余式的基本概念及一次同余式
  • 【Java】关键字-final【主线学习笔记】
  • Java 数据结构 最小栈的实现
  • ES6的简单介绍
  • C++: 类和对象(上)
  • 【EasyBlog】基于React+AntD+NextJS+NestJS+MySQL打造的开源博客系统
  • 深耕电通二十年,崔光荣升电通中国首席执行官
  • Java 入门指南:JVM(Java虚拟机)垃圾回收机制 —— 垃圾回收算法
  • 机器学习-点击率预估-论文速读-20240916
  • markdown-it:将Markdown文本转换为HTML格式,展示在页面,怎么自定义里面的a标签设置为在新标签页打开
  • GEE 案例:如何利用LST脚本快速计算指定区域的LST和时序的LST
  • 14 vue3之内置组件trastion全系列
  • pandas 生成excel多级表头
  • [Java]SpringBoot能力进阶
  • 九章云极DataCanvas公司荣获2024年服贸会“科技创新服务示范案例”
  • 面向对象例题之例题的特性
  • 在Android中fragment的生命周期