Eclipse中CppStyle插件报错clang-format不存在的安装配置问题咨询
Mac端Eclipse CppStyle正确配置步骤
- 第一步:获取clang-format的实际安装路径
打开终端执行命令:which clang-format
复制返回的完整路径,常见安装路径如下:- Homebrew Apple芯片安装:
/opt/homebrew/bin/clang-format - Homebrew Intel芯片安装:
/usr/local/bin/clang-format - Xcode命令行工具安装:
/Library/Developer/CommandLineTools/usr/bin/clang-format
- Homebrew Apple芯片安装:
- 第二步:配置CppStyle插件的clang-format路径
打开Eclipse偏好设置(Eclipse > Preferences),依次进入C/C++ > CppStyle配置页,将第一步获取的完整路径粘贴到「Clang-format path」输入框中,不要留空。 - 第三步:确认格式化器配置正确
检查C/C++ > Code Style > Formatter页,确认代码格式化器已经设置为「CppStyle(clang-format)」,点击「Apply and Close」保存所有配置。 - 第四步:验证效果
打开任意C/C++源文件,按下快捷键Cmd+Shift+F触发格式化,控制台无报错即为配置成功。
若配置后仍提示路径不存在,可执行软连命令将clang-format链接到系统公共路径:
sudo ln -s 你获取的clang-format完整路径 /usr/local/bin/clang-format,之后在CppStyle配置页填写/usr/local/bin/clang-format即可。
内容的提问来源于stack exchange,提问作者JusticeRainsBangBangBang
相关产品推荐
相关产品推荐

