风泥

导航

vscode 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

posted on 2018-06-15 14:49  风泥  阅读(164)  评论(0编辑  收藏  举报