Where are clang-format and clang-format.py in Mac OS X with Xcode Command Line Tools installed?
Solution 1
You can use brew now to install clang-format.
brew install clang-format
Solution 2
I know this is not a direct answer to the question but if you are just looking to format your code in Xcode. I just used this plug in.
https://github.com/travisjeffery/ClangFormat-Xcode
Solution 3
Specific versions of clang-format
As of november/2018, current clang-format
formula on Homebrew points to version 8.0.0
. Run clang-format --version
to check yours.
If you need older versions of clang-format
, consider following these steps:
Installing clang-format version 5 (5.0.2) with homebrew
Installing clang-format version 7 (7.0.0) with homebrew
Solution 4
In my case I installed clang-format with brew install and located here: /usr/local/bin/clang-format
Solution 5
If you have the llvm
toolchain already installed, you can find the clang-format.py
file in /usr/local/opt/llvm/share/clang/clang-format.py
without having to install a separate clang-format
binary through Homebrew.
Ahmed Fasih
Full-stack dev & electrical engineer— JavaScript, TypeScript, Python, C, C++, Elm, Clojure Node, React, Numpy signal processing, machine learning, numerical methods high-performance computing and CUDA GIS (QGIS, GDAL, OGR) Japanese NLP (And I helped with this obnoxious Matlab problem too!) Profile photo via https://www.flickr.com/photos/ain-t_looking_for_nothing/8757900003/
Updated on July 08, 2022Comments
-
Ahmed Fasih almost 2 years
I am having a hard time finding clang-format and clang-format.py on my Mac OS 10.8.5 with Xcode 5 and its Command Line Tools. I tried
find / -name "clang-format.py"
without luck. Are they already here somewhere hiding, or how would I get this toolchain?(I'm surprised it doesn't seem readily available since clang is Apple's compiler---in that Apple uses it.)
-
Ahmed Fasih over 10 yearsCurrently I am not (emacs + vim user), but this is certainly handy to know about.
-
Shane Arney almost 10 yearsIf you use this plugin you can find clang-format in the installed plugin at: ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ClangFormat.xcplugin/Contents/Resources/clang-format
-
Feu about 5 yearsHi @heLomaN , the default
clang-format
on brew installs the latest version from 2018-12-18. (check the PR).