Browse Source

first commit

wangshouqiang 2 years ago
commit
302bbb2942
6 changed files with 91 additions and 0 deletions
  1. 20 0
      .vscode/c_cpp_properties.json
  2. 30 0
      .vscode/launch.json
  3. 28 0
      .vscode/tasks.json
  4. 11 0
      hello.cpp
  5. BIN
      hello.exe
  6. 2 0
      readme.md

+ 20 - 0
.vscode/c_cpp_properties.json

@@ -0,0 +1,20 @@
+{
+    "configurations": [
+        {
+            "name": "Win32",
+            "includePath": [
+                "${workspaceFolder}/**"
+            ],
+            "defines": [
+                "_DEBUG",
+                "UNICODE",
+                "_UNICODE"
+            ],
+            "cStandard": "c17",
+            "cppStandard": "c++17",
+            "intelliSenseMode": "gcc-x64",
+            "compilerPath": "D:/mingw-w64/mingw64/bin/g++.exe"
+        }
+    ],
+    "version": 4
+}

+ 30 - 0
.vscode/launch.json

@@ -0,0 +1,30 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+
+        {
+            "name": "(gdb) Launch",
+            "preLaunchTask": "g++.exe build active file",//调试前执行的任务,就是之前配置的tasks.json中的label字段
+            "type": "cppdbg",//配置类型,只能为cppdbg
+            "request": "launch",//请求配置类型,可以为launch(启动)或attach(附加)
+            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",//调试程序的路径名称
+            "args": [],//调试传递参数
+            "stopAtEntry": false,
+            "cwd": "${workspaceFolder}",
+            "environment": [],
+            "externalConsole": true,//true显示外置的控制台窗口,false显示内置终端
+            "MIMode": "gdb",
+            "miDebuggerPath": "D:\\mingw-w64\\mingw64\\bin\\gdb.exe",
+            "setupCommands": [
+                {
+                    "description": "Enable pretty-printing for gdb",
+                    "text": "-enable-pretty-printing",
+                    "ignoreFailures": true
+                }
+            ]
+        }
+    ]
+}

+ 28 - 0
.vscode/tasks.json

@@ -0,0 +1,28 @@
+{
+	"version": "2.0.0",
+	"tasks": [
+		{
+			"type": "cppbuild",
+			"label": "g++.exe build active file",
+			"command": "D:/mingw-w64/mingw64/bin/g++.exe",
+			"args": [
+				"-fdiagnostics-color=always",
+				"-g",
+				"${file}",
+				"-o",
+				"${fileDirname}\\${fileBasenameNoExtension}.exe"
+			],
+			"options": {
+				"cwd": "D:/mingw-w64/mingw64/bin"
+			},
+			"problemMatcher": [
+				"$gcc"
+			],
+			"group": {
+				"kind": "test",
+				"isDefault": true
+			},
+			"detail": "编译器: D:/mingw-w64/mingw64/bin/g++.exe"
+		},
+	]
+}

+ 11 - 0
hello.cpp

@@ -0,0 +1,11 @@
+#include <iostream>
+using namespace std;
+
+int main(){
+   int a;
+   int b;
+   cin >>a>>b;
+   cout <<a+b<<endl; 
+   getchar();
+   return 0;
+}

BIN
hello.exe


+ 2 - 0
readme.md

@@ -0,0 +1,2 @@
+## vscode 编译c++
+参考 地址 https://zhuanlan.zhihu.com/p/87864677