Vscode

mac m1 Vscode clang 컴파일러 setting file 설정 및 github 연동

SeungbeomKim 2022. 9. 18. 02:00
반응형

tasks.json, launch.json, c_cpp_properties.json의 파일 리팩토링이 필요하다.

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${workspaceFolder}/*.cpp",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ 활성 파일 빌드",
            "command": "/usr/bin/clang++",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "디버거에서 생성된 작업입니다."
        }
    ]
}

launch.json

{
    // 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": "clang++ - Build and debug active file",
        "type": "lldb",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "lldb",
        "preLaunchTask": "clang++ build active file"
      }
    ]
  }

c_cpp_properties.json

{
    "configurations": [
      {
        "name": "Mac",
        "includePath": ["${workspaceFolder}/**"],
        "defines": [],
        "macFrameworkPath": [
          "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
        ],
        "compilerPath": "/usr/bin/clang",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "clang-x64"
      }
    ],
    "version": 4
  }

더불어 자신이 짠 코드 파일 실행을 위한 단축키 설정이 필요하다

Mac : Code -> 기본설정 -> 바로 가기 키

Run code 입력 후 자신이 원하는 컴파일 키로 변경

기존 : ctrl + alt + n -> cmd + r(기호에 맞게 변경)

다음과 같이 자신이 짠 코드를 단축키를 통해 빠르게 실행할 수 있게 된다.

<vscode git 연동>

세 번째 부분에 연결고리 부분을 클릭하면 github에 게시를 클릭해주면 된다.

나는 이미 게시를 했기 때문에 커밋 부분만 보이게 된다.

<참고 자료>

https://code.visualstudio.com/docs/cpp/config-clang-mac

 

Configure VS Code for Clang/LLVM on macOS

Configure the C++ extension in Visual Studio Code to target Clang/LLVM

code.visualstudio.com

https://polarcompass.tistory.com/12

 

[Mac OS] 맥북 M1 vscode C++ 설정 환경 설정 개발환경 세팅 apple silicon

1. VSCODE 다운로드 - mac OS 환경 및 M1 이라면 Apple Silicon 버전 다운로드. 직접 다운로드 https://code.visualstudio.com/#alt-downloads Visual Studio Code - Code Editing. Redefined Visual Studio Code..

polarcompass.tistory.com

 

반응형