关于VScode变量
  • 板块灌水区
  • 楼主蒟酱厂妹
  • 当前回复5
  • 已保存回复5
  • 发布时间2022/3/5 22:53
  • 上次更新2023/10/28 07:11:24
查看原帖
关于VScode变量
310818
蒟酱厂妹楼主2022/3/5 22:53

众所周知在.vsocde//launch.json中有个

"args": [
	"/c cd ${fileDirname} && g++ ${fileBasename} -o ${fileBasenameNoExtension} -O2 -Wall -Wextra -pedantic -std=c++20 && .vscode\\ConsolePauser ${fileBasenameNoExtension}"
],

其中${fileDirname}表示文件夹的绝对位置,${fileBasename}表示有后缀的文件名称,${fileBasenameNoExtension}表示无后缀的文件名称,ConsolePauser是从Dev-c++贺来的exe文件,使用这个结束后会自动暂停。以上这段话经过本人东拼西凑在没有空格的情况下非常良好,但是在文件名有空格时会炸掉,于是我采取和插件Code Runner无法编译带空格时同样做法增加引号\"(显然要转义符),但是在Code Runner中显灵的方式却不灵了,这要如何是好? 以下是本人的配置

//tasks.json
{
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe 生成活动文件",
			"command": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "调试器生成的任务。"
		}
	],
	"version": "2.0.0"
}
//launch.json
{
	// 使用 IntelliSense 了解相关属性。 
	// 悬停以查看现有属性的描述。
	// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "g++.exe - 生成和调试活动文件",
			"type": "cppdbg",
			"request": "launch",
			"program": "C:\\Windows\\System32\\cmd.exe", //这两行的说明在下面
			"args": [
				"/c cd ${fileDirname} && g++ ${fileBasename} -o ${fileBasenameNoExtension} -O2 -Wall -Wextra -pedantic -std=c++20 && .vscode\\ConsolePauser ${fileBasenameNoExtension}"
			],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": true, //改成true
			"internalConsoleOptions": "neverOpen", //这条加的,终端貌似还是会打开
			"MIMode": "gdb",
			"miDebuggerPath": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\gdb.exe",
			"setupCommands": [
				{
					"description": "为 gdb 启用整齐打印",
					"text": "-enable-pretty-printing",
					"ignoreFailures": false //这个改成false
				}
			],
			"preLaunchTask": "C/C++: g++.exe 生成活动文件"
		}
	]
}
//c_cpp_properties.json
{
	"configurations": [
		{
			"name": "Win32",
			"includePath": [
				"${workspaceFolder}/**"
			],
			"defines": [
				"_DEBUG",
				"UNICODE",
				"_UNICODE"
			],
			"compilerPath": "C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\bin\\gcc.exe",
			"cStandard": "gnu17",
			"intelliSenseMode": "windows-gcc-x64"
		}
	],
	"version": 4
}

最后的最后捞2个帖子
P1073最优贸易 记忆化dfs20分求助
关于powershell和中括号

2022/3/5 22:53
加载中...