Skip to content

Commit 73286f5

Browse files
committed
general update project 11/05/2024 10:49:12
1 parent 8739b2f commit 73286f5

13 files changed

+566
-83
lines changed

.vscode/launch.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"type": "cppdbg",
1515
"request": "launch",
1616
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
17-
"program": "${fileDirname}\\a.exe",
17+
// "program": "${fileDirname}\\a.exe",
18+
"program": "${workspaceFolder}\\a.exe",
1819
"args": [],
1920
"stopAtEntry": false,
20-
"cwd": "${fileDirname}",
21+
"cwd": "${workspaceFolder}",//注意和对应的task配合
2122
"environment": [],
2223
"externalConsole": false,
2324
"MIMode": "gdb",
@@ -206,7 +207,7 @@
206207
"name": "C/C++: g++.exe build and run active file(no debug)", // 配置名称
207208
"type": "cppdbg",
208209
"request": "launch",
209-
"program": "${fileDirname}/a.exe", // 指向编译生成的可执行文件
210+
"program": "${workspaceFolder}/a.exe", // 指向编译生成的可执行文件
210211
"args": [], // 可选参数,传递给程序的命令行参数
211212
"cwd": "${workspaceFolder}", // 设置工作目录
212213
// "console": "integratedTerminal", // 在 VSCode 的集成终端中运行

.vscode/launch.json.bak

+218
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
// 对于一个脚本和C++控制台小程序的工作区,可以存放多种编程语言源文件,比如可以将python的调试配置也可以放进来,和C/C++的debug方案放在一起,充当configurations数组的元素,这样一个工作区可以通过选择包含在本文件的不同的配置来调试不同语言的程序
5+
// {
6+
// "name": "Python Debugger: Current File",
7+
// "type": "debugpy",
8+
// "request": "launch",
9+
// "program": "${file}",
10+
// "console": "integratedTerminal"
11+
// },
12+
{
13+
"name": "C/C++: g++.exe build and debug active file(Recommend for C++(by The way C) Starter)",
14+
"type": "cppdbg",
15+
"request": "launch",
16+
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
17+
"program": "${fileDirname}\\a.exe",
18+
"args": [],
19+
"stopAtEntry": false,
20+
"cwd": "${fileDirname}",
21+
"environment": [],
22+
"externalConsole": false,
23+
"MIMode": "gdb",
24+
"miDebuggerPath": "gdb",
25+
"setupCommands": [
26+
{
27+
"description": "Enable pretty-printing for gdb",
28+
"text": "-enable-pretty-printing",
29+
"ignoreFailures": true
30+
},
31+
{
32+
"description": "Set Disassembly Flavor to Intel",
33+
"text": "-gdb-set disassembly-flavor intel",
34+
"ignoreFailures": true
35+
}
36+
],
37+
"preLaunchTask": "task2"
38+
},
39+
{
40+
"name": "C/C++: gcc.exe build and debug active file(Recommend for C(by The way c++) Starter)",
41+
"type": "cppdbg",
42+
"request": "launch",
43+
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
44+
"program": "${fileDirname}\\a.exe",
45+
"args": [],
46+
"stopAtEntry": false,
47+
"cwd": "${fileDirname}",
48+
"environment": [],
49+
"externalConsole": false,
50+
"MIMode": "gdb",
51+
"miDebuggerPath": "gdb",
52+
"setupCommands": [
53+
{
54+
"description": "Enable pretty-printing for gdb",
55+
"text": "-enable-pretty-printing",
56+
"ignoreFailures": true
57+
},
58+
{
59+
"description": "Set Disassembly Flavor to Intel",
60+
"text": "-gdb-set disassembly-flavor intel",
61+
"ignoreFailures": true
62+
}
63+
],
64+
"preLaunchTask": "task2c"
65+
},
66+
{
67+
"name": "C/C++: g++.exe build and debug active file external console",
68+
"type": "cppdbg",
69+
"request": "launch",
70+
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
71+
"program": "${fileDirname}\\a.exe",
72+
"args": [],
73+
"stopAtEntry": false,
74+
"cwd": "${fileDirname}",
75+
"environment": [],
76+
"externalConsole": true, //设置打开外部终端进行调试(个别情况需要在代码中使用system("Pause")来避免一闪而过)
77+
// 通常没有必要设置为外部终端打开,vscode内的集成终端以及足够使用了;
78+
// vscode中程序执行完毕后外置终端就会自动退出,除非使用Pause来阻止退出
79+
// Pause可以在源代码末尾中添加system("Pause");但是这就显得有些繁琐了,Dev C++等IDE会自动执行这个命令,而不需要我们手动设置
80+
// 目前vscode c/c++ extension 没有支持这种自动pause的功能
81+
"MIMode": "gdb",
82+
"miDebuggerPath": "gdb",
83+
"setupCommands": [
84+
{
85+
"description": "Enable pretty-printing for gdb",
86+
"text": "-enable-pretty-printing",
87+
"ignoreFailures": true
88+
},
89+
{
90+
"description": "Set Disassembly Flavor to Intel",
91+
"text": "-gdb-set disassembly-flavor intel",
92+
"ignoreFailures": true
93+
}
94+
],
95+
"preLaunchTask": "task externalConsole"
96+
},
97+
{
98+
"name": "C/C++: g++.exe build and debug the C++ language files",
99+
"type": "cppdbg",
100+
"request": "launch",
101+
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
102+
"program": "${fileDirname}\\All.exe",
103+
"args": [],
104+
"stopAtEntry": false,
105+
"cwd": "${fileDirname}",
106+
"environment": [],
107+
"externalConsole": false,
108+
"MIMode": "gdb",
109+
// "miDebuggerPath": "${env:MSYS2_MINGW}\\gdb.exe",
110+
"miDebuggerPath": "gdb",
111+
"setupCommands": [
112+
{
113+
"description": "Enable pretty-printing for gdb",
114+
"text": "-enable-pretty-printing",
115+
"ignoreFailures": true
116+
},
117+
{
118+
"description": "Set Disassembly Flavor to Intel",
119+
"text": "-gdb-set disassembly-flavor intel",
120+
"ignoreFailures": true
121+
}
122+
],
123+
// "preLaunchTask": "C/C++: g++.exe build active file"
124+
"preLaunchTask": "task1"
125+
},
126+
{
127+
"name": "C/C++: g++.exe build and debug the C language files",
128+
"type": "cppdbg",
129+
"request": "launch",
130+
"program": "${fileDirname}\\All.exe",
131+
"args": [],
132+
"stopAtEntry": false,
133+
"cwd": "${fileDirname}",
134+
"environment": [],
135+
"externalConsole": false,
136+
"MIMode": "gdb",
137+
"miDebuggerPath": "gdb",
138+
"setupCommands": [
139+
{
140+
"description": "Enable pretty-printing for gdb",
141+
"text": "-enable-pretty-printing",
142+
"ignoreFailures": true
143+
},
144+
{
145+
"description": "Set Disassembly Flavor to Intel",
146+
"text": "-gdb-set disassembly-flavor intel",
147+
"ignoreFailures": true
148+
}
149+
],
150+
"preLaunchTask": "task1c"
151+
},
152+
{
153+
"name": "C/C++: g++.exe build and debug active file(For English, Chinese characters and other non-English characters)",
154+
"type": "cppdbg",
155+
"request": "launch",
156+
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
157+
"program": "${fileDirname}\\a.exe",
158+
"args": [],
159+
"stopAtEntry": false,
160+
"cwd": "${fileDirname}",
161+
"environment": [],
162+
"externalConsole": false,
163+
"MIMode": "gdb",
164+
"miDebuggerPath": "gdb",
165+
"setupCommands": [
166+
{
167+
"description": "Enable pretty-printing for gdb",
168+
"text": "-enable-pretty-printing",
169+
"ignoreFailures": true
170+
},
171+
{
172+
"description": "Set Disassembly Flavor to Intel",
173+
"text": "-gdb-set disassembly-flavor intel",
174+
"ignoreFailures": true
175+
}
176+
],
177+
"preLaunchTask": "task2"
178+
},
179+
{
180+
"name": "C/C++: g++.exe build and debug active file",
181+
"type": "cppdbg",
182+
"request": "launch",
183+
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
184+
"args": [],
185+
"stopAtEntry": false,
186+
"cwd": "${fileDirname}",
187+
"environment": [],
188+
"externalConsole": false,
189+
"MIMode": "gdb",
190+
"miDebuggerPath": "gdb",
191+
"setupCommands": [
192+
{
193+
"description": "Enable pretty-printing for gdb",
194+
"text": "-enable-pretty-printing",
195+
"ignoreFailures": true
196+
},
197+
{
198+
"description": "Set Disassembly Flavor to Intel",
199+
"text": "-gdb-set disassembly-flavor intel",
200+
"ignoreFailures": true
201+
}
202+
],
203+
"preLaunchTask": "task3"
204+
},
205+
{
206+
"name": "C/C++: g++.exe build and run active file(no debug)", // 配置名称
207+
"type": "cppdbg",
208+
"request": "launch",
209+
"program": "${workspaceFolder}/a.exe", // 指向编译生成的可执行文件
210+
"args": [], // 可选参数,传递给程序的命令行参数
211+
"cwd": "${workspaceFolder}", // 设置工作目录
212+
// "console": "integratedTerminal", // 在 VSCode 的集成终端中运行
213+
"stopAtEntry": false,
214+
"preLaunchTask": "build and run", // 指定预执行的编译任务名称
215+
"internalConsoleOptions": "neverOpen"
216+
}
217+
]
218+
}

.vscode/tasks.json

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
// https://code.visualstudio.com/docs/editor/variables-reference
3+
/*
4+
5+
*/
6+
27
"tasks": [
38
{
49
"type": "cppbuild",
@@ -10,8 +15,8 @@
1015
"${file}",
1116
"-o",
1217
"${fileDirname}\\a.exe",
13-
"-finput-charset=UTF-8",
14-
"-fexec-charset=gbk"
18+
//"-finput-charset=UTF-8",
19+
//"-fexec-charset=gbk"
1520
],
1621
"options": {
1722
"cwd": "${fileDirname}"
@@ -72,14 +77,15 @@
7277
"args": [
7378
"-fdiagnostics-color=always",
7479
"-g",
75-
"${file}",
80+
"${file}",//如果不使用cwd,那么考虑使用 "${fileNameDir}//${file}"
7681
"-o",
77-
"${fileDirname}\\a.exe",
78-
"-finput-charset=UTF-8",
79-
"-fexec-charset=gbk"
82+
// "${fileDirname}\\a.exe",
83+
"${workspaceFolder}\\a.exe",
84+
//"-finput-charset=UTF-8",
85+
//"-fexec-charset=gbk"
8086
],
8187
"options": {
82-
"cwd": "${fileDirname}"
88+
"cwd": "${fileDirname}"//根据喜好是否使用这个选项(跳转工作目录到源文件所在目录,也可以将工作目录写在args的源文件选项里)
8389
},
8490
"problemMatcher": [
8591
"$gcc"
@@ -98,9 +104,10 @@
98104
// "-std=c99",
99105
"-lstdc++", //支持编译c/c++两种语言,gcc 需要用上-lstdc++,但是尽量用g++编译c++,避免潜在的问题
100106
"-o",
101-
"${fileDirname}\\a.exe",
102-
"-finput-charset=UTF-8",
103-
"-fexec-charset=gbk"
107+
// "${fileDirname}\\a.exe",
108+
"a.exe",
109+
//"-finput-charset=UTF-8",
110+
//"-fexec-charset=gbk"
104111
],
105112
"options": {
106113
"cwd": "${fileDirname}"
@@ -122,9 +129,9 @@
122129
// "-std=c99",
123130
"-lstdc++", //支持编译c/c++两种语言,gcc 需要用上-lstdc++,但是尽量用g++编译c++,避免潜在的问题
124131
"-o",
125-
"${fileDirname}\\a.exe",
126-
"-finput-charset=UTF-8",
127-
"-fexec-charset=gbk"
132+
"${workspaceFolder}\\a.exe",
133+
//"-finput-charset=UTF-8",
134+
//"-fexec-charset=gbk"
128135
],
129136
"options": {
130137
"cwd": "${fileDirname}"
@@ -135,6 +142,11 @@
135142
"group": "build",
136143
"detail": "build and run active file(c/c++ source code single file),non-english path may cause error."
137144
},
145+
{
146+
"label": "echo",
147+
"type": "shell",
148+
"command": "echo ${workspaceFolder}"
149+
},
138150
{
139151
"type": "cppbuild",
140152
"label": "task3",
@@ -145,8 +157,8 @@
145157
"${file}",
146158
"-o",
147159
"${fileDirname}\\${fileBasenameNoExtension}.exe",
148-
"-finput-charset=UTF-8",
149-
"-fexec-charset=gbk"
160+
//"-finput-charset=UTF-8",
161+
//"-fexec-charset=gbk"
150162
],
151163
"options": {
152164
"cwd": "${fileDirname}"

0 commit comments

Comments
 (0)