ycm配置


YCM需要设置include path,如果设置的不正确会导致函数的定义不对或者fix错误,那如何设置正确的路径呢。
从stackoverflow上面搜到的答案,换成了类似的写法。

g++ -E -xc++ - -Wp,-v < /dev/null

可以得到结果为

/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed
/usr/include

那么我们的.ycm_extra_config.py需要换成

'-isystem',
'/usr/include/c++/11.2.0',
'-isystem',
'/usr/include/c++/11.2.0/x86_64-pc-linux-gnu',
'-isystem',
'/usr/include/c++/11.2.0/backward',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed',

同理可以弄C语言

'-isystem',
'/usr/local/include',
'-isystem',
'/usr/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed',

Author: 蒋璋
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source 蒋璋 !