For c++ dev


For c++ dev

前置

  • 配一个mobaxterm(professional edition v20),用来传文件。

离线vscode server

  • 用华为云的时候发现vscode server老是下载不成功,于是用离线下载
  • 记得关闭自动更新,,否则下次又得重新安装。
    • https://jingyan.baidu.com/article/ed15cb1b12fa265ae2698165.html
  • 一般来说,装下C/C++Chinesecmakegitlensmarkdown all in onecode spell checker,远程开发需要remote那几个

plugin

  • 离线安装只需要要网页上下载vsix文件就可以了
  • https://marketplace.visualstudio.com/VSCode

format

  • search format
{
	"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 120, AccessModifierOffset: -2, PointerAlignment: Right, ObjCBlockIndentWidth: 4}",
	"editor.minimap.maxColumn": 80,
	"cpplint.verbose": 2,
	"remote.autoForwardPortsSource": "output",
	"C_Cpp.clang_format_style": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 120, AccessModifierOffset: -2, PointerAlignment: Right, ObjCBlockIndentWidth: 4}",
	"files.insertFinalNewline": true,
}

vs debug

.vscode/launch.json中配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            // "program": "/home/kemingzeng/workplace/west/build/west/bin/ut_tests",
            // "args": ["--gtest_filter=TestPackage.test_package_open_fs:-*Persistence*"],
            "program": "/home/kemingzeng/workplace/west/output/bin/west",
            "args": ["./demo_lef_10000macro.lef"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

exclude

.vscode/settings.json里面可以配置

{
    "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/tmp/**": true,
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist/**": true,
        "**/log/**": true,
        "**/logs/**": true,
        "**/.fdk/**": true,
        "**/extension/**": false,
        "**/parser/**": true,
        "**/schema/**": true,
        "**/coverage_report/**": true,
    },
    "files.exclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/tmp/**": true,
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist/**": true,
        "**/log/**": true,
        "**/.fdk/**": true,
        "**/extension/**": false,
        "**/parser/**": false,
        "**/schema/**": true,
    },
    "search.exclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/tmp/**": true,
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist/**": true,
        "**/log/**": true,
        "**/extension/**": false,
        "**/parser/**": true,
        "**/schema/**": true,
        "**/coverage_report/**": true,
    },
    "files.associations": {
        "type_traits": "cpp",
        "string": "cpp",
        "vector": "cpp",
        "array": "cpp",
        "*.tcc": "cpp",
        "deque": "cpp",
        "list": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "hash_map": "cpp",
        "hash_set": "cpp",
        "slist": "cpp",
        "string_view": "cpp",
        "new": "cpp",
        "atomic": "cpp",
        "bitset": "cpp",
        "cctype": "cpp",
        "chrono": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "condition_variable": "cpp",
        "csignal": "cpp",
        "cstdarg": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "forward_list": "cpp",
        "exception": "cpp",
        "fstream": "cpp",
        "functional": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "ostream": "cpp",
        "numeric": "cpp",
        "ratio": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "system_error": "cpp",
        "thread": "cpp",
        "cinttypes": "cpp",
        "regex": "cpp",
        "tuple": "cpp",
        "utility": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "cstddef": "cpp",
        "algorithm": "cpp",
        "iterator": "cpp",
        "map": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "set": "cpp",
        "variant": "cpp",
        "stack": "cpp",
        "codecvt": "cpp",
        "strstream": "cpp",
        "complex": "cpp",
        "cfenv": "cpp",
        "typeindex": "cpp",
        "*.inc": "cpp",
        "future": "cpp"
    }
}

c_cpp_properties

  • defines 可以解决条件编译在vscode里的显示问题

  • .vscode/c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.4.0/../../../../include/c++/8.4.0/**",
                "/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.4.0/../../../../include/c++/8.4.0/x86_64-pc-linux-gnu/**",
                "/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.4.0/../../../../include/c++/8.4.0/backward/**",
                "/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.4.0/include/**",
                "/usr/local/include/**",
                "/usr/local/lib/gcc/x86_64-pc-linux-gnu/8.4.0/include-fixed/**",
                "/usr/include/**"
            ],
            "defines": ["MEMORY_PI1_3"],
            "compilerPath": "/usr/local/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4,
    "env": {
        "WEST_MEM_DEV_OPT": "PI1_3"
    }
}