vscode c++

本文档详细介绍了如何在VSCode中配置C++环境,包括安装必要的插件、设置c_cpp_properties.json文件以实现智能感知及代码高亮等功能,以及创建tasks.json文件来支持编译和运行C++程序。

VSCODE + C++

参考文档:https://code.visualstudio.com/docs/languages/cpp
1. 安装插件"C/C++"

2. 工程配置

生成c/c++配置文件,按"Ctrl+Shift+P",选择"C/Cpp: Edit configurations..."生成"c_cpp_properties.json"文件。

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true
            },
            "includePath": [
                "${workspaceFolder}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilePath": "D:\\MinGW\\mingw64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}


3. 工程编译

生成"tasks.json",按"Ctrl+Shift+P",选择"Task: Configure Tasks...",选择"Create task.json file from templates",选择"Others",生成"tasks.json"文件。

task.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "main.cpp",
                "-o",
                "hellowrold.exe"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

编译配置

tasks.json中添加了vs2015与g++两种编译方式
1. vs2015

使用vs2015编译程序,需要自己写makefile, 此demo的makefile中会生成“应用程序”“多态库”

2. g++

直接调用gcc编译文件,不需要makefile

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值