Closed stokhos closed 4 years ago
~Try set "clangd.arguments": ["-std=c++17"]
to your coc-settings.json.~
Use "clangd.fallbackFlags": [ "-std=c++17" ]
.
How can I do this? Do I need to unninstall coc-clangd? below is my coc-settings.json { "languageserver": { "clangd": { "command": "clangd", "args": ["--background-index", "-std=c++17"], "rootPatterns": ["compile_flags.txt", "compile_commands.json"], "filetypes": ["c", "cpp"] }, } this works, but is there a way of not deleting coc-clangd and add "clangd.arguments": ["-std=c++17"] to your coc-settings.json at same time?
To clarify, the flag -std=c++17
is not passed to the clangd binary argument, it needs to be added in the compilation command. If you use the compile_flags.txt
, just put it there.
is there a way of not deleting coc-clangd and add "clangd.arguments": ["-std=c++17"] to your coc-settings.json at same time?
Yes, if you use coc-clangd, the coc-settings.json is like below (not other fields)
{
"clangd.arguments": [...]
}
It works. Thanks guys!
i did as you said in the second comment in this thread and i now get
[coc.nvim] The "clangd" server crashed 5 times in the last 3 minutes. The server will not be restarted.
P.S. putting it into compile_flags.txt works tho, but i would rather not do that every time i start a new project
that's WAI, as indicated in Haojian's comment
To clarify, the flag -std=c++17 is not passed to the clangd binary argument, it needs to be added in the compilation command. If you use the compile_flags.txt, just put it there.
if you pass it to clangd, command line parsing will fail and clangd will exit with a non-zero error code.
Yes, if you use coc-clangd, the coc-settings.json is like below (not other fields)
{ "clangd.arguments": [...] }
Doing this make clangd crash very quickly. Not recommended anymore.
I can't get C++17 support, so many errors. It isn't able to find string_view
even. Can anyone suggest something else?
Doing this make clangd crash very quickly
Well, are you putting clangd flags in there? -std=c++17
is not a clangd flag, it must go in your compile_commands.json or compile_flags.txt instead.
(clangd will not crash in this case, but it won't start correctly either).
Incidentally, if you really want to set this globally for all projects, the next release (clangd 11) will make this possible.
I used the clangd.fallbackFlags
option and it worked fine for me. This is my coc-settings.json
:
{
"clangd.fallbackFlags": [ "-std=c++17" ]
}
I have found the compile_flags.txt
method to be the best. However I still have the problem where clangd thinks .h
files are C header files so it keeps complaining
you can also put -xc++-header
into your compile_flags.txt
I used the
clangd.fallbackFlags
option and it worked fine for me. This is mycoc-settings.json
:{ "clangd.fallbackFlags": [ "-std=c++17" ] }
It's works! It's take me hole day to setting this config, every solution from internet didn't work.ðŸ˜
I used the
clangd.fallbackFlags
option and it worked fine for me. This is mycoc-settings.json
:{ "clangd.fallbackFlags": [ "-std=c++17" ] }
I'm trying C++ in VSCode with clangd. I need this:
"clangd.fallbackFlags": [
"-std=c++2a",
],
to turn off the error messages in problem pane in VSCode, e.g.:
No member named 'exchange' in namespace 'std'
It has to be in "clangd.fallbackFlags". If I put it in "clangd.arguments", the outline view does not work.
I opened the output of coc-clangd to see why this solution is not working for me and this is what I got:
:CocCommand workspace.showOutput clangd
clangd: Unknown command line argument '-std=c++17'. Try: '/usr/bin/clangd --help'
clangd: Did you mean '--j=c++17'?
@MuhammadSawalhy what's your clangd version?
@MuhammadSawalhy what's your clangd version?
I switched to clangd.fallbackFlags
instead of clangd.arguments
and it works now. Thanks!
This doesn't work with C files!
How to use clangd.fallbackFlags
with cpp files only?
Read the following link carefully, then use compile commands to solve your problems.
// workspace settings: //.vscode/settings.json "clangd.fallbackFlags": [ //"-std=c99", "-I../foo", ],
for C files, I comment the -std option
// workspace settings:
I am coding separate and independent C++ and C files in the same project. This is my repo which contains solutions for problems from sites like LeetCode, Hackerrank, and Codeforces.
So I need a way to configure -std
flag differently for C++ and C files.
// workspace settings:
I am coding separate and independent C++ and C files in the same project. This is my repo which contains solutions for problems from sites like LeetCode, Hackerrank, and Codeforces.
So I need a way to configure
-std
flag differently for C++ and C files.
@MuhammadSawalhy Have you found a solution for having the -std
flag separately for C and C++ files?
"clangd.fallbackFlags": [ "-std=c++17" ]
It works! Thanks for your reply!
Hi,
Is there a way to set clangd only work with c++ 17 standard? best