Skip to content

Commit 58585d3

Browse files
committed
Use clang-format 20
1 parent e449e31 commit 58585d3

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

.github/workflows/clang-format.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ jobs:
3333
sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool
3434
- name: Install clang-format 20
3535
run: |
36-
sudo apt-get install -y clang-format-20
37-
sudo ln -sf /usr/bin/clang-format-20 /usr/bin/clang-format
36+
# Download pre-built binary directly
37+
cd /tmp
38+
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.1/clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04.tar.xz
39+
tar xf clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04.tar.xz
40+
sudo cp clang+llvm-20.1.1-x86_64-linux-gnu-ubuntu-22.04/bin/clang-format /usr/local/bin/clang-format
3841
clang-format --version
3942
- name: Install Re2c
4043
run: |

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,23 @@ First, install clang-format:
208208

209209
```bash
210210
# macOS
211-
brew install clang-format
211+
brew install clang-format@20
212+
brew link clang-format@20
212213

213214
# Ubuntu/Debian
214-
sudo apt-get install clang-format
215+
# Add LLVM repo and install version 20
216+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
217+
sudo apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-20 main"
218+
sudo apt-get update
219+
sudo apt-get install -y clang-format-20
220+
sudo ln -sf /usr/bin/clang-format-20 /usr/bin/clang-format
215221

216222
# Windows
217-
choco install llvm
223+
choco install llvm --version=20.0.0
218224
```
219225

226+
> **Important**: This project requires clang-format version 20.x for consistent formatting. Using other versions may result in formatting inconsistencies between local development and CI.
227+
220228
#### Usage
221229

222230
Format all C source files:
@@ -231,6 +239,12 @@ Check formatting without making changes:
231239
rake format:c_check
232240
```
233241

242+
Verbose check that shows differences:
243+
244+
```bash
245+
rake format:c_verbose
246+
```
247+
234248
#### Editor Integration
235249

236250
For VS Code users, install the "clangd" extension which will automatically use the project's `.clang-format` file.

0 commit comments

Comments
 (0)