[C++] - Tips

1 minute read

💻 Setting of Visual Studio Code (for M1 MacBook)

  • Install Visual Studio Code (Apple Silicon)
  • Add Extensions in Visual Studio Code: C/C++ and Code Runner
  • Open Extension Settings → Code-runner: Excutor Map By File Extension → Edit in settings.json
this is a placeholder image
Images > Push to Hub
this is a placeholder image
Images > Push to Hub
  • Fill the settings.json as follows (If settings are already described, do not remove but update them)

    • {
          "git.ignoreMissingGitWarning": true,
          "code-runner.runInTerminal": true,      
          "C_Cpp.updateChannel":"Insiders",
          "editor.multiCursorModifier": "ctrlCmd",
          "C_Cpp.default.cppStandard": "c++17",
          "C_Cpp.default.cStandard": "c11",
          "code-runner.executorMap": {
                  
              "javascript": "node",
              "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
              "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "php": "php",
              "python": "python -u",
              "perl": "perl",
              "perl6": "perl6",
              "ruby": "ruby",
              "go": "go run",
              "lua": "lua",
              "groovy": "groovy",
              "powershell": "powershell -ExecutionPolicy ByPass -File",
              "bat": "cmd /c",
              "shellscript": "bash",
              "fsharp": "fsi",
              "csharp": "scriptcs",
              "vbscript": "cscript //Nologo",
              "typescript": "ts-node",
              "coffeescript": "coffee",
              "scala": "scala",
              "swift": "swift",
              "julia": "julia",
              "crystal": "crystal",
              "ocaml": "ocaml",
              "r": "Rscript",
              "applescript": "osascript",
              "clojure": "lein exec",
              "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
              "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
              "racket": "racket",
              "scheme": "csi -script",
              "ahk": "autohotkey",
              "autoit": "autoit3",
              "dart": "dart",
              "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
              "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
              "haskell": "runhaskell",
              "nim": "nim compile --verbosity:0 --hints:off --run",
              "lisp": "sbcl --script",
              "kit": "kitc --run",
              "v": "v run",
              "sass": "sass --style expanded",
              "scss": "scss --style expanded",
              "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
              "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
              "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
          }
      }
      
    • cpp elements should be set as "cpp": "cd $dir && g++ -std=c++17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
  • Installation of C/C++ Compiler

    • Installation of homebrew

      • $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
        
    • Install cask

      • $ brew install cask
        
    • After installation of xcode, C/C++ Compiler is installed

      • $ xcode-select --install
        

Reference

Tags:

Categories:

Updated: