首页 >> 生活

常用Clangd提升C++代码编写体验

时间:2023-04-21 12:18:12

,函数模板不统一,数据类型命名准则等:

4.当今化时C++,如常见auto,using,override等当今C++优点:

(vscode + Community Material米色 + Error Lens应用流程,Error Lens应用流程常用将出错定时从外部展示在字符串后)

如何常见装配

clangd有三种装配方式将:

的系统包监管:如mac的系统可常见brew install llvm,debian/ubuntu可常见sudo apt-get install clangd-14 等等

手动下载二进位:可以在手动下载最上新版本的二进位

手动PHP:可以参看#building-and-testing-clangd从源码PHP

个人更推荐后两种方式将,因为最上新的动态比如多种类型定时要在上新版本的clangd才有

配有界面

以vscode为例,首先在应用流程市场装配clangd应用流程,在此在此之后在vscode配有此前去掉如下几行

"clangd.arguments": [ ";还有clang-tidy", // 打开clang-tidy ";还有all-scopes-completion", // 正因如此字符串库补正因如此 ";还有completion-style=detailed", // 详细补正因如此 ";还有header-insertion=iwyu", ";还有pch-storage=disk", // 如果内存够大可以关闭这个可选择 ";还有log=error", ";还有j=5", // 本该内核数,可根据机器配有再行修正 ";还有background-index" ],"clangd.path": "", "[cpp]": { "editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"},单项配有

clangd只能并不知道如何PHP你的单项,因此只能一个“PHP数据库”,通常情况下我们只能向clangd共享一个compile_commands.json档案,这个档案的转换成只能依赖于你的PHP的系统:

CMAKE:cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 去掉这个模板才会

BAZEL:可以常见这个应用流程

其他:大多数PHP的系统更亦会共享自己的compile commands转换成方式将,如果没有人,或者是很老的单项,则可以通过应用流程利用

WXG Patchbuild:APP的patchbuild备用大力支持compile_commands.json转换成,在正常的PHP命令后加上;还有download-genfiles ;还有compile-command-query=;还有merge后运行,patchbuild亦会把当前期望的compile_commands.json转换成,并与本地的~/QQMail/compile_commands.json合并,供clangd常见:

patchbuild build ;还有download-genfiles ;还有compile-command-query=;还有merge :

对于每一个源档案,clangd亦会备用向上层,以及每层的build档案夹寻找compile_commands.json,如果你转换成的档案在其他重定向,可以通过ln -s ~/myproject-build/compile_commands.json ~/myproject/ 创建粗连接起来解决原因。

clang-tidy配有

clang-tidy的各项健康检查可以通过一个配有档案配有,在单项的FAT下去掉一个.clang-tidy(这就是档案名,".clang-tidy"),可以参看我的,然后根据期望自己搭配:

;还有-Checks:> -*, bugprone-*, google-*, misc-*, modernize-*, performance-*, portability-*, readability-*, -modernize-use-trailing-return-type, -bugprone-lambda-Function-name, -google-runtime-references, -readability-magic-numbers, -bugprone-easily-swappable-parameters, -readability-identifier-length, -bugprone-narrowing-conversions,# Turn all the warnings from the checks above into errors.WarningsAsErrors: "performance-*, bugprone-*"CheckOptions: - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - { key: readability-identifier-naming.ClassCase, value: CamelCase } - { key: readability-identifier-naming.StructCase, value: CamelCase } - { key: readability-identifier-naming.TemplateParameterCase, value: aNy_CasE } - { key: readability-identifier-naming.FunctionCase, value: aNy_CasE } - { key: readability-identifier-naming.VariableCase, value: lower_case } - { key: readability-identifier-naming.ClassMemberCase, value: lower_case } - { key: readability-identifier-naming.ClassMemberSuffix, value: _ } - { key: readability-identifier-naming.PrivateMemberSuffix, value: _ } - { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } - { key: readability-identifier-naming.EnumConstantCase, value: CamelCase } - { key: readability-identifier-naming.EnumConstantPrefix, value: k } - { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase } - { key: readability-identifier-naming.ConstexprVariablePrefix, value: k } - { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase } - { key: readability-identifier-naming.GlobalConstantPrefix, value: k } - { key: readability-identifier-naming.MemberConstantCase, value: CamelCase } - { key: readability-identifier-naming.MemberConstantPrefix, value: k } - { key: readability-identifier-naming.StaticConstantCase, value: CamelCase } - { key: readability-identifier-naming.StaticConstantPrefix, value: k } - { key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1 } - { key: readability-function-cognitive-complexity.Threshold, value: 100 }

对于每一项配有的意涵,可以参看:

同时也可以参看开源单项的配有,如google cloud的: 或者apache arrow的:

clang-format配有

同理,在单项FAT下去掉.clang-format档案,用与clangd备用载入,可以参看开源单项的简化,比如:和

概述

工欲善其事,必先利其器。LLVM单项热卖的Clangd以外稳定的玩游戏、充分利用的动态和热衷于的的社区,它作为一个稳定高效的C++字符串应用流程可以成倍地大幅提高我们的字符串编所写玩游戏,是每个C++开发者大幅提高字符串稳定性的不二之选。

肠胃不舒服吃什么药
水土不服拉肚子
吃什么止泻快
孩子不吃饭怎么办
解毒药
TAG:代码
友情链接: