This commit is contained in:
Even Bell 2025-03-25 15:05:55 +08:00
parent 0e0c08b4eb
commit 235e1fb8e5
7 changed files with 214 additions and 11 deletions

17
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}

60
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,60 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "GDB启动调试C",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc编译C代码"
},
{
"name": "GDB启动调试C++",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "g++编译C++代码"
}
]
}

73
.vscode/settings.json vendored
View File

@ -1,12 +1,65 @@
{ {
"c-cpp-compile-run.c-flags": "-fdiagnostics-color=always -Wall -g", /* Code Runner */
"c-cpp-compile-run.output-location": "build", "code-runner.runInTerminal": true,
"c-cpp-compile-run.save-before-compile": true, "code-runner.saveAllFilesBeforeRun": true,
"c-cpp-compile-run.should-show-notifications": false, "code-runner.executorMap": {
"C_Cpp.clang_format_style": "LLVM", "c": "cd $dir && gcc $fileName -fexec-charset=GBK -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"[c]": { "cpp": "cd $dir && g++ $fileName -fexec-charset=GBK -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"files.encoding": "gbk"
}, },
"editor.tabSize": 2, "C_Cpp.clang_format_style": "Microsoft",
"files.eol": "\n" "C_Cpp.debugShortcut": false,
} "editor.tabSize": 4,
"files.eol": "\n",
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"span": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"text_encoding": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
},
}

43
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,43 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "gcc编译C代码",
"command": "gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Mingw64 C编译"
},
{
"type": "cppbuild",
"label": "g++编译C++代码",
"command": "g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Mingw64 C++编译"
},
],
"version": "2.0.0"
}

View File

@ -1,2 +1,9 @@
#include <stdio.h> #include <stdio.h>
int main() { printf("你好,世界!"); } int main()
{
printf("你好,世界!\n");
char input[256];
printf("Input> ");
scanf("%s", input);
printf("Ouput: %s\n", input);
}

11
0.run/helloworld.cc Normal file
View File

@ -0,0 +1,11 @@
#include <iostream>
int main()
{
using namespace std;
string input;
cout << "你好,世界!" << endl;
cout << "Input> ";
cin >> input;
cout << "Output: " << input << endl;
}

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# VSCode C/C++ 运行代码配置
- 使用的编译器为 **mingw64**
- 所需的VSCode插件
* **Code Runner** 用于基本的编译运行代码,支持中文输入输出
* **Microsoft C/C++** 用于代码提示补全及调试功能,调试模式不支持中文输出
> [!WARNING]
> 代码文件及所处的路径不能包含中文字符,调试环境不能解析中文路径
> [!WARNING]
> 再次运行当前程序,务必确保程序已经终止运行,新的程序文件无法覆盖旧的正在运行中的程序文件,可在终端使用`Ctrl C`终止。