'Where are clang-format and clang-format.py in Mac OS X with Xcode Command Line Tools installed?
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.)
Solution 1:[1]
You can use brew now to install clang-format.
brew install clang-format
Solution 2:[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.
Solution 3:[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:
Solution 4:[4]
In my case I installed clang-format with brew install and located here: /usr/local/bin/clang-format
Solution 5:[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.
Solution 6:[6]
If you have installed clang-format via brew, the clang-format has been downloaded under
(Just use my [email protected] with upgrade from [email protected] as an example)
/usr/local/Cellar/clang-format@5/
with it's executable file clang-format under
/usr/local/Cellar/clang-format@5/5.0.2/bin/clang-format
with it's configuration file clang-format.py under
/usr/local/Cellar/clang-format@5/5.0.2/share/clang/clang-format.py
ALso,
the [email protected] will create soft link executable file clang-format under
/usr/local/bin/clang-format -> ../Cellar/clang-format@5/5.0.2/bin/clang-format
(that's why while I check where the clang-format is no matter using where clang-format or which clang-format or even whereis clang-format, that always shows /usr/local/bin/clang-format.)
(If you want to check where soft link /usr/local/bin/clang-format linked to?
Just use the command to check cd /usr/local/bin/ && pwd && ls -al | grep "clang-format", liking mine showing:)
/usr/local/bin/clang-format -> ../Cellar/clang-format@5/5.0.2/bin/clang-format
and the [email protected] soft link create configuration file clang-format.py under
/usr/local/share/clang/clang-format.py
the upstairs soft link linked to
/usr/local/Cellar/clang-format@5/5.0.2/share/clang/clang-format.py
Others,
somebody's download [email protected] maybe under
/usr/local/Cellar/clang-format
with executable file clang-formatunder
/usr/local/Cellar/clang-format/2019-01-18/bin/clang-format
with configuration file clang-format.py under
/usr/local/Cellar/clang-format/2019-01-18/share/clang/clang-format.py
withe the upstairs soft link clang-format.py under
/usr/share/clang/clang-format-3.8/clang-format.py
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 | johnhaley81 |
| Solution 2 | Gustavo Barcena |
| Solution 3 | |
| Solution 4 | Alibek Taalaibek Uulu |
| Solution 5 | second.string |
| Solution 6 | Vittore Marcas |
