Skip to content

Commit

Permalink
update styleguide
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz-h committed Jul 26, 2023
1 parent f8967e2 commit 904731d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,21 @@ PointerAlignment: Left
SpaceAfterCStyleCast: false # want true, but has issues with clang-format-12
SpaceAfterTemplateKeyword: false
Standard: c++17
# TODO Does not work reliable, yet. Do not use in automatic CI pipeline!
# Relies on having <> vs. "" correctly set, is missing POSIX/Win32 headers and other edge cases.
# Uncomment to use locally for at least semi automated fixup.
#IncludeBlocks: Regroup
#IncludeCategories:
# # C headers (https://en.cppreference.com/w/cpp/header)
# - Regex: '<(assert|complex|ctype|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|uchar|wchar|wctype)\.h>'
# Priority: 1
# # C++ headers: assume <>, no slash, no extension
# - Regex: '<([A-Za-z0-9_])+>'
# Priority: 2
# # Library headers: all other assume <>
# - Regex: '<([A-Za-z0-9./_-])+>'
# Priority: 3
# # Local headers: assume ""
# - Regex: '"([A-Za-z0-9./_-])+"'
# Priority: 4
...
12 changes: 7 additions & 5 deletions docs/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ There, the original formatting should be kept.
## File Organization

- Use `#pragma once` and do not use include guards.
- Split includes into 4 groups, each group is ordered alphabetically, empty line between groups:
1. Corresponding Header to the current .cpp file (with `""`).
2. System Includes (with `<>`)
3. External Library Includes (with `<>`[^6])
4. MegaMol internal includes (with `""`)
- Split includes into groups, each group is ordered alphabetically, empty line between groups:
1. Corresponding header to the current .cpp file (with `""`).
2. C system headers (with `<>`[^6])
3. C++ STL headers (with `<>`[^6])
4. External library headers (with `<>`[^6])
5. MegaMol internal headers (headers in this repository) (with `""`)
6. Conditional includes requiring `#ifdef` after all others
- Header files use the extension `.h`, source files `.cpp`
- Files names must match the corresponding class name (also in `UpperCamelCase`).
- Directory names must match the corresponding namespace (at least for top level categorisation, additional subdirectories may or may not introduce an additional namespace level).
Expand Down

0 comments on commit 904731d

Please sign in to comment.