'Vim YouCompleteMe c++17 : warning on decomposition declaration
I would like to set YouCompleteMe correctly so that I do not get the following warning on a c++ file:
...
auto [k,v] = mapIt; // some map iterator
...
decomposition declarations are a C++17 extension
I added
flags.append( '-std=c++17' )
in
~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py
and added the following to
~/.vimrc
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
Solution 1:[1]
I decided to remove the previous installation and do everything from the command line (assuming previous Vundle installation as recommended in YouCompleteMe docs).
# typical installation directory for vundle and pathogen
cd ~/.vim/bundle
# clone the repository for YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
# and all submodules
git submodule update --init --recursive
# install
python3 install.py --clang-completer
Next I created a simple ycm_extra_conf.py (without the .dot) containing:
def FlagsForFile ( filename, **kwargs ):
return {
'flags': ['-x', '-Wall', '-Wextra', '-Werror', '-std=c++2a']
}
I added the c++2a flag, but c++17 should also work.
Then point to this file in your ~/.vimrc file.
let g:ycm_global_ycm_extra_conf = '$HOME/.vim/bundle/YouCompleteMe/ycm_extra_conf.py'
Note: you may have to add to your ~/.vimrc
Plugin 'Valloric/YouCompleteMe'
in your vimrc file.
And run (from vim)
:PluginInstall
I didn't do these steps as I had installed YouCompleteMe previously.
This seems to have fixed the problem for me. Hope this can be useful for someone.
Solution 2:[2]
just change the flag '-std=c++11' to '-std=c++17' in the .ycm_extra_conf.py .
that works for me perfectly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frankie Y. Liu |
| Solution 2 | kroos |
