프로그래밍 언어/PS를 위한 C++

[PS를 위한 C++] 2. VS Code C++ 개발 환경 설정

nageune 2023. 10. 7. 10:40
728x90
반응형

대부분 C++로 개발할 때 Windows 사용자들은 Visual Studio를 사용할 것이고 mac 사용자들은 Xcode를 사용할 것입니다. 물론 둘 다 충분히 훌륭한 ide지만, VS Code의 Extension들을 포기하지 못한 저 같은 사람들은 VS Code를 써야겠죠. 그를 위한 설정입니다.
 

확장 프로그램

  • C/C++
  • C/C++ Extension Pack
  • C/C++ Themes

 

settings.json

{
  "files.associations": {
		"iostream": "cpp",
		"__bit_reference": "cpp",
		"__bits": "cpp",
		"__config": "cpp",
		"__debug": "cpp",
		"__errc": "cpp",
		"__hash_table": "cpp",
		"__locale": "cpp",
		"__mutex_base": "cpp",
		"__node_handle": "cpp",
		"__nullptr": "cpp",
		"__split_buffer": "cpp",
		"__string": "cpp",
		"__threading_support": "cpp",
		"__tuple": "cpp",
		"array": "cpp",
		"atomic": "cpp",
		"bit": "cpp",
		"bitset": "cpp",
		"cctype": "cpp",
		"chrono": "cpp",
		"clocale": "cpp",
		"cmath": "cpp",
		"compare": "cpp",
		"complex": "cpp",
		"concepts": "cpp",
		"cstdarg": "cpp",
		"cstddef": "cpp",
		"cstdint": "cpp",
		"cstdio": "cpp",
		"cstdlib": "cpp",
		"cstring": "cpp",
		"ctime": "cpp",
		"cwchar": "cpp",
		"cwctype": "cpp",
		"exception": "cpp",
		"initializer_list": "cpp",
		"ios": "cpp",
		"iosfwd": "cpp",
		"istream": "cpp",
		"limits": "cpp",
		"locale": "cpp",
		"memory": "cpp",
		"mutex": "cpp",
		"new": "cpp",
		"optional": "cpp",
		"ostream": "cpp",
		"ratio": "cpp",
		"sstream": "cpp",
		"stdexcept": "cpp",
		"streambuf": "cpp",
		"string": "cpp",
		"string_view": "cpp",
		"system_error": "cpp",
		"tuple": "cpp",
		"type_traits": "cpp",
		"typeinfo": "cpp",
		"unordered_map": "cpp",
		"variant": "cpp",
		"vector": "cpp",
		"__functional_base": "cpp",
		"algorithm": "cpp",
		"functional": "cpp",
		"iterator": "cpp",
		"utility": "cpp",
		"regex": "cpp",
		"random": "cpp",
		"deque": "cpp",
		"fstream": "cpp",
		"iomanip": "cpp",
		"numeric": "cpp",
		"stack": "cpp",
		"filesystem": "cpp",
		"list": "cpp",
		"__tree": "cpp",
		"cfenv": "cpp",
		"cinttypes": "cpp",
		"condition_variable": "cpp",
		"csetjmp": "cpp",
		"csignal": "cpp",
		"forward_list": "cpp",
		"future": "cpp",
		"map": "cpp",
		"queue": "cpp",
		"scoped_allocator": "cpp",
		"set": "cpp",
		"thread": "cpp",
		"typeindex": "cpp",
		"unordered_set": "cpp",
		"valarray": "cpp",
		"__verbose_abort": "cpp"
	},
	"C_Cpp.errorSquiggles": "enabled",
}

 

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++ clang++ build active file",
      "command": "/usr/bin/clang++",
      "args": [
        "-std=c++17",
        "-fcolor-diagnostics",
        "-fansi-escape-codes",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": [
        "$gcc"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "compiler: /usr/bin/clang++",
      "presentation": {
          "revealProblems": "onProblem",
          "close": true
      }
    }
  ]
}

 

  1. 위 확장 프로그램들을 모두 설치한다.
  2. 해당 VS Code 프로젝트 폴더 내부에 .vscode 폴더를 만든다.
  3. .vscode 폴더 내부에 settings.json과 tasks.json을 만든다.
  4. 코드를 작성하고 F5를 누르면 코드가 실행된다.

 

728x90
반응형