style/README.md

43 lines
930 B
Markdown
Raw Permalink Normal View History

2025-01-14 13:19:25 -05:00
# Style Guide
This document lays out my general style guide when writing code, mostly in C.
## General Opinions
- Lines should try to be at most 80 columns.
- Four (4) spaces in a tab. No tab characters.
- THE POINTER GOES ON THE LEFT.
- Single line (`//`) comments for comments on the code. Multi-line (`/**/`) for
other things, e.g. examples, algorithm explanations, narratives, &c.
## Line Breaks
In general, keep things on as few lines as possible / legible. Obviously, this
means function declarations should be on one line if possible. Keep as best as
possible to an 80-column limit.
Examples:
```C
looooooooooooooooooong type
llllllllllong_function_name(with a, lot of, arguments* h) {
return something;
}
```
```C
// Skip all whitespace.
while (*inp == ' ' || *inp == '\t') inp++;
```
## Comment Style
2025-01-14 13:21:50 -05:00
In comments, use markdown.
```C
// Print `var`.
void print(char* var) {
printf("%s\n", var);
}
```