- Avoid global state. Prefer passing dependencies explicitly.
- No magic numbers — use named constants or enums.
- Match the style of the surrounding code when in doubt.
| Kind | Convention | Example |
|---|---|---|
| Types, classes | PascalCase |
NodeId, AudioBus |
| Functions, methods | camelCase |
addToHead, isGroup |
| Member variables | m_ prefix |
m_first, m_engine |
| Enum constants | kMethcla_ prefix |
kMethcla_NodePlacementHeadOfGroup |
| Macros | METHCLA_ prefix |
METHCLA_EXPORT |
- Use
conston variables, parameters, and member functions wherever possible. - Use
constexprinstead ofconstfor compile-time constants. - Use
nullptr, notNULLor0for pointers. - Use
size_tfor sizes and counts. Cast once at the boundary; don't scatter casts. - Use
static_castfor explicit conversions. Avoid C-style casts.
- Mark overriding methods
override. Do not also mark themvirtual.
- Header guards:
#ifndef METHCLA_<PATH>_HPP_INCLUDED/#define/#endif. - Include order: own header first, then internal headers, then third-party, then standard library. Each group separated by a blank line.
Methcla::for C++ API.- Anonymous namespace for translation-unit-local helpers instead of
static.
Enforced by clang-format. Configuration is in .clang-format. Run pre-commit run --all-files rather than formatting manually.
- All public symbols prefixed
methcla_(functions) orMethcla_(types). - Enum constants prefixed
kMethcla_. typedef structandtypedef enum— no anonymous structs.extern "C"guards in every public header.METHCLA_EXPORTon all exported symbols.snake_casefor all identifiers.- Header guards:
#ifndef METHCLA_<NAME>_H_INCLUDED.
- Type annotations on all function signatures.
pathlib.Pathfor file paths, not string concatenation.subprocess.run(..., check=True)— don't silently swallow non-zero exit codes.- Keep scripts short and single-purpose. Extract helpers only when reused.
Enforced by black. Run pre-commit run --all-files rather than formatting manually.