See example.cpp for a simple example of the style I use.
.clang-format
is a clang-format style file containing the rules for spacing, indentation, max
line width etc.
You can format example.cpp with clang-format -i example.cpp
(this will automatically load the
.clang-format file)
Variables should be snake case: int my_var = 0;
Typedefs should be snake_case
with a _t
identifier:
typedef int my_favourite_type_t;
Structs should be snake_case
and typedef'd, like so:
typedef struct my_struct {
int struct_member;
} my_struct_t;
Class names should follow a CamelCase
format:
class MyClassInCamelCase {
Class functions should be snake_case
:
class MyClassInCamelCase {
void has_function_in_snake_case();
};
Member variables should also be denoted with an m_
, like so:
class MyClassInCamelCase {
void has_function_in_snake_case();
int m_var;
};