../
C Naming Convention
| Symbol | Scheme |
|---|---|
| variable | snake_case |
| function | snake_case |
| constants | SNAKE_CASE |
| structs | snake_case_struct |
| enums | snake_case_enum |
- Don’t use typedefs unless you want them to be intentionally opaque
- The supposed rationale of this is that when you encounter some type
type_t *ayou have no clue about that the heckais - It make the code obscure. It doesn’t improve visibility.
- Though it may seem verbose, use
void foo(struct foo_struct *bar) - This is stolen from the kernel docs
- Also
_tis reserved by POSIX
- The supposed rationale of this is that when you encounter some type
Naming functions
- Name function using the pattern
object_verb()instead ofverb_object() - This allows for very easy grepping
- If you start typing in
object_you can see all the things you can do with that object - example would be
vector_addvector_subetc… - Instead of
add_vector()you cannot easily autocomplete stuff