Skip to content

Commit 624a83b

Browse files
committed
Tools: Add instructions for fixing include format
1 parent cb1c64f commit 624a83b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/tools/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ For each file, `clang-tidy` will first try to compile it and then run the enable
7878
The messages are redirected into `clang-tidy.log`.
7979
The file name and the exit code are printed below the output of `clang-tidy` so that you can get the list of files for which `clang-tidy` failed with `grep " 1$" "clang-tidy.log"`.
8080

81+
## Fixing include format
82+
83+
Headers from the same project should be included using quotation marks (`#include "path/header.h"`), all other headers should be included using angle brackets (`#include <path/header.h>`).
84+
Failing to do so can result in picking a wrong header.
85+
See more details in the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf12-prefer-the-quoted-form-of-include-for-files-relative-to-the-including-file-and-the-angle-bracket-form-everywhere-else).
86+
87+
The [`format_includes.awk`](https://github.com/AliceO2Group/O2Physics/blob/master/Scripts/format_includes.awk) script allows to fix the include format in a provided O2Physics file.
88+
89+
To fix the include format in all `.h`, `.cxx` files in the current directory, execute:
90+
91+
```bash
92+
find . -name "*.h" -o -name "*.cxx" | parallel "awk -f Scripts/format_includes.awk \"{}\" > \"{}.tmp\" && mv \"{}.tmp\" \"{}\""
93+
```
94+
8195
## [cppcheck](https://cppcheck.sourceforge.io/)
8296

8397
`cppcheck` is a static analysis tool for C/C++ code that detects bugs, undefined behaviour, and dangerous coding constructs that compilers typically miss.

0 commit comments

Comments
 (0)