VScode编译环境设置

MinGW这个自己去下载

注意如果之前安装了,又安装了一遍,需要把第一次的环境变量给清空。

配置文件

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${default}",
                "D:\\MinGW\\mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "compilerPath": "D:\\MinGW\\mingw64/bin/g++.exe"
        }
    ],
    "version": 4
}

cpp.code-snippets

{
	// Place your algorithm-edu 工作区 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {
	// 	"scope": "javascript,typescript",
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"usermain": {
		"prefix": "#in",
		"body": [
			"#include",
			"using namespace std;",
		   "int main(){",
		   "$1 ",
		   " ",
		   " ",
		   "return 0;",
		   "}"
		],
		"description": "初始化"
	},
	"userfor": {
		"prefix": "fors",
		"body": [
			"for(int $1=0;$1< ;$1++){",
			" ",
		   " ",
		   " ",
		   "}"
		],
		"description": "for"
	},
	"userif": {
		"prefix": "ifs",
		"body": [
			"if($1){",
			" ",
		   " ",
		   "}"
		],
		"description": "if"
	},
	"pause": {
		"prefix": "pau",
		"body": [
			"system(\"pause\");",
		],
		"description": "暂停"
	},
	"fpss": {
		"prefix": "frop",
		"body": [
			" freopen(\"in.in\",\"r\",stdin);",
			"freopen(\"out.in\",\"w\",stdout);",
		],
		"description": "文件重定向"
	},
	"usermain2": {
		"prefix": "#fp",
		"body": [
			"#include",
			"using namespace std;",
		   "int main(){",
		   " freopen(\"in.in\",\"r\",stdin);",
		   "freopen(\"out.in\",\"w\",stdout);",
		   "$1 ",
		   " ",
		   " ",
		   "return 0;",
		   "}"
		],
		"description": "带有文件重定向的初始化"
}
}

 launch.json

 

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",//生成的exe文件存放处
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,//是否显示为win32控制台
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\MinGW\\mingw64\\bin\\gdb.exe",		/*修改成自己bin目录下的gdb.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++"
        }
    ]
}

settings.json

{
    "editor.mouseWheelZoom": true,
    "editor.tokenColorCustomizations": {
      "comments": "#89f47f", // 注释
     "keywords": "#cd77ff", // 关键字
      "variables": "#57aefa", // 变量名
      "strings": "#ffda8fbd", // 字符串
      "functions": "#feffcc", // 函数名
      "numbers": "#ffffff", // 数字

  },
  "files.associations": {
    "stdio.h": "c",
    "ostream": "cpp",
    "array": "cpp",
    "atomic": "cpp",
    "*.tcc": "cpp",
    "cctype": "cpp",
    "clocale": "cpp",
    "cmath": "cpp",
    "cstdarg": "cpp",
    "cstddef": "cpp",
    "cstdint": "cpp",
    "cstdio": "cpp",
    "cstdlib": "cpp",
    "cstring": "cpp",
    "cwchar": "cpp",
    "cwctype": "cpp",
    "deque": "cpp",
    "unordered_map": "cpp",
    "vector": "cpp",
    "exception": "cpp",
    "algorithm": "cpp",
    "map": "cpp",
    "memory": "cpp",
    "memory_resource": "cpp",
    "optional": "cpp",
    "string": "cpp",
    "string_view": "cpp",
    "system_error": "cpp",
    "tuple": "cpp",
    "type_traits": "cpp",
    "utility": "cpp",
    "fstream": "cpp",
    "initializer_list": "cpp",
    "iosfwd": "cpp",
    "iostream": "cpp",
    "istream": "cpp",
    "limits": "cpp",
    "new": "cpp",
    "sstream": "cpp",
    "stdexcept": "cpp",
    "streambuf": "cpp",
    "typeinfo": "cpp",
    "valarray": "cpp",
    "bitset": "cpp",
    "cfenv": "cpp",
    "charconv": "cpp",
    "chrono": "cpp",
    "cinttypes": "cpp",
    "codecvt": "cpp",
    "complex": "cpp",
    "condition_variable": "cpp",
    "csetjmp": "cpp",
    "csignal": "cpp",
    "ctime": "cpp",
    "cuchar": "cpp",
    "forward_list": "cpp",
    "list": "cpp",
    "unordered_set": "cpp",
    "functional": "cpp",
    "iterator": "cpp",
    "numeric": "cpp",
    "random": "cpp",
    "ratio": "cpp",
    "regex": "cpp",
    "set": "cpp",
    "future": "cpp",
    "iomanip": "cpp",
    "mutex": "cpp",
    "scoped_allocator": "cpp",
    "shared_mutex": "cpp",
    "thread": "cpp",
    "typeindex": "cpp"
  },
  "C_Cpp.autocompleteAddParentheses": true,
  "C_Cpp.clang_format_fallbackStyle": "Google"
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
        "type": "shell",
        "label": "task g++",
        "command": "D:\\MinGW\\mingw64\\bin\\g++.exe",	/*修改成自己bin目录下的g++.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
        "args": [
            "-g",
            "${file}",
            "-o",
            "${workspaceFolder}\\${fileBasenameNoExtension}.exe",//生成的exe文件存放处
            "-I",
            "${workspaceFolder}",   //生成的exe文件存放处   /*修改成自己放c/c++项目的文件夹,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
            "-std=c++17",
        ],
        "options": {
            "cwd": "D:\\MinGW\\mingw64\\bin"	/*修改成自己bin目录,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
        },
        "problemMatcher":[
            "$gcc"
        ],
        "group": "build",
        
        }
    ]
}

你可能感兴趣的:(vscode,c++,ide)