mirror of
https://github.com/hyprwm/hyprland-wiki.git
synced 2024-11-22 12:45:59 +01:00
add clang format notes
This commit is contained in:
parent
b597ca16a0
commit
2f1b29815f
1 changed files with 3 additions and 47 deletions
|
@ -6,53 +6,9 @@
|
|||
|
||||
## Code Style
|
||||
|
||||
Hyprland's code style:
|
||||
Hyprland's code style is governed by the `.clang-format` file.
|
||||
|
||||
```cpp
|
||||
void myFunction(int arg) {
|
||||
|
||||
if (shortStatement)
|
||||
doSomething();
|
||||
else
|
||||
doNotDoIt();
|
||||
|
||||
switch (value) {
|
||||
case 1:
|
||||
{ // braces optional
|
||||
blahBlah();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Debug::log(ERR, "error");
|
||||
break;
|
||||
}
|
||||
|
||||
const auto CONSTVALUE = arg == 1 ? 2 : 3;
|
||||
|
||||
void* pLocalPointer = nullptr;
|
||||
|
||||
int localValue = 0;
|
||||
|
||||
if (MY && VERY && LONG && IF && STATEMENT && OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO && SUPERLONG && STATEMENT) {
|
||||
; // blank
|
||||
}
|
||||
}
|
||||
|
||||
class myClass {
|
||||
public:
|
||||
int m_iMyLocalInt = 0;
|
||||
// ^ member
|
||||
// ^ int
|
||||
// ^ camel name
|
||||
|
||||
void classFunction(int, int, bool defaultBool = false);
|
||||
// ^ most arg names omitted
|
||||
// ^ arg name mandatory here because C++
|
||||
|
||||
// Note: omitting args only for functions with clear / few args. For long functions:
|
||||
void classFunctionLong(int a, int b, bool sure, bool red, bool enabled, void* item, const CColor& color = {0});
|
||||
}
|
||||
```
|
||||
Make sure to format accordingly whenever you make a PR.
|
||||
|
||||
## Some code FAQ
|
||||
|
||||
|
|
Loading…
Reference in a new issue