Skip to content

Instantly share code, notes, and snippets.

@190ikp
Last active January 31, 2023 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 190ikp/d55d8b6e4ff0e898220c8666ec34c54c to your computer and use it in GitHub Desktop.
Save 190ikp/d55d8b6e4ff0e898220c8666ec34c54c to your computer and use it in GitHub Desktop.
VSCode setting at Keio ITC

ITCのLinux環境でC言語を書くときの設定

VSCodeを使って書くときの設定ファイル

ITCの環境はincludeとgccのバイナリが変な場所にあって,VSCodeがデフォルト設定のままではF5デバッグできないので...

フォーマッタはプロ3の演習で指定される形式のものにしています

必要なもの

つかいかた

作業するディレクトリ内に.vscodeディレクトリを作って,その中にsettings.json, launch.json, tasks.json, c_cpp_properties.jsonを置くだけ

あとはF5で雑にデバッグできるようになる

settings.jsonC_Cpp.errorSquigglesはdisableにしておかないとうまくエラーハンドリングしてくれないことがある

注意点

ITCの環境がちょっと特殊なだけなので,他の環境ではデフォルトのままで動くと思います

ここの設定ファイルを使う場合はgdbgcc,includeの場所を環境に合わせて書き換えてください

{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/",
"/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c89",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
{
"recommendations": [
"ms-vscode.cpptools"
]
}
{
// 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": "gcc build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc build active file",
"miDebuggerPath": "/bin/gdb"
}
]
}
{
"files.associations": {
".h": "c"
},
"editor.formatOnSave": true,
"C_Cpp.clang_format_style": "{ BasedOnStyle: WebKit, UseTab: ForIndentation, IndentWidth: 4, TabWidth: 4, ColumnLimit: 80, NamespaceIndentation: All, AlignTrailingComments: true, PointerAlignment: Right, MaxEmptyLinesToKeep: 3, ColumnLimit: 80, IndentPPDirectives: BeforeHash }",
"C_Cpp.dimInactiveRegions": false
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc build active file",
"command": "/bin/gcc",
"args": [
"-g",
"${file}",
"-lm",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment