简体   繁体   English

有没有办法在不重新编译的情况下指定clangd的c++标准?

[英]Is there a way to specify the c++ standard of clangd without recompiling it?

I'm trying to use a feature in c++17(const lambdas) without having clangd error me.我正在尝试使用 c++17(const lambdas) 中的一个功能,而不会出现 clangd 错误。 I've searched online and every answer tells me to recompile clangd with a flag.我在网上搜索过,每个答案都告诉我用标志重新编译clangd。 Is there truly no other way?真的没有别的办法了吗?

Edit: Clangd is not the compiler.编辑:Clangd 不是编译器。 It's a language server, which is a program made to be used with IDEs that basically checks your code for errors and warnings before compiling it.它是一个语言服务器,它是一个与 IDE 一起使用的程序,它基本上在编译代码之前检查您的代码是否存在错误和警告。 See https://clangd.llvm.org .请参阅https://clangd.llvm.org

Answer inspired by n.n 启发的答案。 1.8e9-where's-my-share m. 1.8e9-where's-my-share m。

From https://clangd.llvm.org/config#compileflags :https://clangd.llvm.org/config#compileflags

You can create a config file for clangd.您可以为 clangd 创建一个配置文件。 In the config file, you can specify the compiler options mimicked.在配置文件中,您可以指定模仿的编译器选项。 For my question, do this:对于我的问题,请执行以下操作:

CompileFlags:
  Add: [-std=c++20, -Wall]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM