• C++ in VSCode


    # C++ in VSCode
    
    ## Extensions
    
    - C/C++ - Microsoft
    - CMake - twxs
    - CMake Tools - Microsoft
    - Code Runner - Jun Han [_options_]
    
    ### Format Settings
    
    1. Format style
    
       Input text to key `C_Cpp: Clang_format_fallback Style` in vscode settings
    
       ```txt
       {BasedOnStyle: Google}
       ```
    
       Or, append text in settings.json
    
       ```json
       "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google}"
       ```
    
    2. Format on save
    
      Append text in settings.json
    
      ```json
      "[cpp]":{
        "editor.formatOnSave": true
      },
      ```
    
    ## macOS Requirement
    
    - Xcode
    - CMake
    
      `brew install cmake`
    
    ## CMake
    
    ### CMake Configure
    
    Press `Cmd+Shift+P`, input `CMake: Configure`.
    
    ### CMake Debug
    
    1. Open `.vscode/settings.json`, append configure [_only for macOS_]
    
       ```json
       "cmake.debugConfig": {
            "miDebuggerPath": "${env:HOME}/.vscode/extensions/ms-vscode.cpptools-0.26.3/debugAdapters/lldb/bin/lldb-mi"
        }
       ```
    
    2. Set a breakpoint in main, then press `Cmd+Shift+P`, input `CMake: Debug`.
    
    ## std version
    
    ```sh
    # touch main.cpp
    g++ -std= -o main main.cpp
    ```
    
    result:
    
    ```sh
    error: invalid value '' in '-std='
    note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
    note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
    note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
    note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
    note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
    note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
    note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
    note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
    note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
    note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
    ```
  • 相关阅读:
    第二阶段冲刺报告(三)
    第二阶段冲刺报告(二)
    第二阶段冲刺报告(一)
    课程改进意见
    用户体验
    返回一个二维整数数组中最大联通子数组的和
    《你的灯亮着吗》阅读笔记三 ——谁的问题
    《你的灯亮着吗》阅读笔记二 ——什么是真正的问题
    《你的灯亮着吗》阅读笔记一 —— 问题是什么?
    我爱淘冲刺阶段站立会议2每天任务6
  • 原文地址:https://www.cnblogs.com/Bob-wei/p/12329615.html
Copyright © 2020-2023  润新知