From 235e1fb8e5283df6a951b0f453ed95191c84e2d7 Mon Sep 17 00:00:00 2001 From: Even Bell <130771607+2000e@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:05:55 +0800 Subject: [PATCH] reconfig --- .vscode/c_cpp_properties.json | 17 ++++++++ .vscode/launch.json | 60 ++++++++++++++++++++++++++++ .vscode/settings.json | 73 ++++++++++++++++++++++++++++++----- .vscode/tasks.json | 43 +++++++++++++++++++++ 0.run/helloworld.c | 9 ++++- 0.run/helloworld.cc | 11 ++++++ README.md | 12 ++++++ 7 files changed, 214 insertions(+), 11 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 0.run/helloworld.cc create mode 100644 README.md diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..f5ad7cc --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "windows-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d249b46 --- /dev/null +++ b/.vscode/launch.json @@ -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++代码" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 54f99ac..5191e82 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,65 @@ { - "c-cpp-compile-run.c-flags": "-fdiagnostics-color=always -Wall -g", - "c-cpp-compile-run.output-location": "build", - "c-cpp-compile-run.save-before-compile": true, - "c-cpp-compile-run.should-show-notifications": false, - "C_Cpp.clang_format_style": "LLVM", - "[c]": { - "files.encoding": "gbk" + /* Code Runner 配置 */ + "code-runner.runInTerminal": true, + "code-runner.saveAllFilesBeforeRun": true, + "code-runner.executorMap": { + "c": "cd $dir && gcc $fileName -fexec-charset=GBK -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "cpp": "cd $dir && g++ $fileName -fexec-charset=GBK -o $fileNameWithoutExt && $dir$fileNameWithoutExt", }, - "editor.tabSize": 2, - "files.eol": "\n" -} + "C_Cpp.clang_format_style": "Microsoft", + "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" + }, +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d730938 --- /dev/null +++ b/.vscode/tasks.json @@ -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" +} \ No newline at end of file diff --git a/0.run/helloworld.c b/0.run/helloworld.c index 38c2368..69df50e 100644 --- a/0.run/helloworld.c +++ b/0.run/helloworld.c @@ -1,2 +1,9 @@ #include -int main() { printf("ã磡"); } \ No newline at end of file +int main() +{ + printf("你好,世界!\n"); + char input[256]; + printf("Input> "); + scanf("%s", input); + printf("Ouput: %s\n", input); +} \ No newline at end of file diff --git a/0.run/helloworld.cc b/0.run/helloworld.cc new file mode 100644 index 0000000..ce7556a --- /dev/null +++ b/0.run/helloworld.cc @@ -0,0 +1,11 @@ +#include + +int main() +{ + using namespace std; + string input; + cout << "你好,世界!" << endl; + cout << "Input> "; + cin >> input; + cout << "Output: " << input << endl; +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8642991 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# VSCode C/C++ 运行代码配置 + +- 使用的编译器为 **mingw64** +- 所需的VSCode插件 + * **Code Runner** 用于基本的编译运行代码,支持中文输入输出 + * **Microsoft C/C++** 用于代码提示补全及调试功能,调试模式不支持中文输出 + +> [!WARNING] +> 代码文件及所处的路径不能包含中文字符,调试环境不能解析中文路径 + +> [!WARNING] +> 再次运行当前程序,务必确保程序已经终止运行,新的程序文件无法覆盖旧的正在运行中的程序文件,可在终端使用`Ctrl C`终止。