Skip to content

Commit

Permalink
Add C project file
Browse files Browse the repository at this point in the history
  • Loading branch information
kenvix committed Jul 28, 2019
0 parents commit 50f95ba
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
16 changes: 16 additions & 0 deletions C-Project/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "MinGW",
"intelliSenseMode": "gcc-x64",
"compilerPath": "C:\\RT\\msys64\\mingw64\\bin\\gcc.exe",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
31 changes: 31 additions & 0 deletions C-Project/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// 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",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/build/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
// 这里填你 MinGW-w64 安装目录下的 gdb 路径
"miDebuggerPath": "C:\\RT\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
// 这里要与你在 tasks.json 中配置的 label 一致
"preLaunchTask": "compile",
}
]
}
22 changes: 22 additions & 0 deletions C-Project/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// 在终端中运行编译命令,否则我们无法与程序通过标准输入交互
"code-runner.runInTerminal": true,
// 如果你全局设置中的默认终端是 WSL 之类的,那么可以在工作区设置中改回 PowerShell
//"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
// 运行代码之前清除之前的输出
"code-runner.clearPreviousOutput": true,
// 开启这个后在运行编译命令之前会自动 cd 至文件所在目录
"code-runner.fileDirectoryAsCwd": true,
// 因为上面那个选项会自动 cd,所以我删除了默认编译命令中的 cd 语句
// 同时我将编译结果的输出目录修改为了同目录下的 build 文件夹
// 不然源码文件和编译结果混杂在一个目录中非常杂乱(尤其是刷题时)
// 这里只保留了 C 和 C++ 的编译命令,有需要其他语言的请自行添加
"code-runner.executorMap": {
"c": "cls && gcc $fileName -o build/$fileNameWithoutExt && .\\build\\$fileNameWithoutExt",
"cpp": "cls && g++ $fileName -o build/$fileNameWithoutExt && .\\build\\$fileNameWithoutExt",
},
// 运行代码后切换焦点至终端,方便直接输入测试数据
"code-runner.preserveFocus": false,
// 在运行代码之前保存文件
"code-runner.saveFileBeforeRun": true,
}
40 changes: 40 additions & 0 deletions C-Project/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"\"${file}\"",
"-o",
"\"${fileDirname}\\build\\${fileBasenameNoExtension}\""
],
"presentation": {
"reveal": "always",
"panel": "shared",
"focus": false,
"echo": true
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
9 changes: 9 additions & 0 deletions C-Project/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>

int main() {
int number = 666;
char* string = "ads8f4sdfg15fsdg15re1g5sdf1";

printf("hello world: %d %s", number, string);
return 0;
}

0 comments on commit 50f95ba

Please sign in to comment.