-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodestyle.txt
More file actions
88 lines (61 loc) · 2.14 KB
/
codestyle.txt
File metadata and controls
88 lines (61 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
C++ Coding Style Guide
1. Namespaces
- Do not use using namespace ...; anywhere.
- Do not use using std::string; or similar. Always use fully qualified
names (e.g. std::string).
2. Underscore Usage
- Never use _ as a prefix or postfix.
- _ may only appear between letters (e.g. MAX_COUNT).
3. Naming Conventions
- Default naming style is camelCase.
- Types (classes, structs, enums) start with a capital letter.
- Functions start with a lowercase letter and use camelCase.
4. Variables & Parameters
4.1 Local Variables
- Must use camelCase.
- Must be prefixed with l.
4.2 Function Parameters
- Value or const-value: prefix with a
- References: prefix with r
- Pointers: prefix with p
4.3 Class Members
- Members use camelCase.
- Normal members use prefix m.
- Pointer members use prefix mp.
4.4 Global Variables
- Avoid globals whenever possible.
- If absolutely necessary, prefix with g.
5. Constants
- Use UPPER_SNAKE_CASE.
- Applies to const, constexpr, and enum values.
6. Types
- Classes, structs, enums, and aliases must start with a capital
letter.
- Do not use typedef or using alias unless a well‑justified technical
reason exists.
- use std::string instead of char*.
- use uint8_t instead of unsigned char.
- use int8_t instead of signed char.
- use uint16_t instead of unsigned short.
- use int16_t instead of signed short.
- use uint32_t instead of unsigned int.
- use int32_t instead of signed int.
- use uint64_t instead of unsigned long long.
- use int64_t instead of signed long long.
- use auto instead of explicit type declarations.
7. Functions
- Functions must begin with a lowercase letter.
- Use camelCase.
8. Casting
- Only C-style casts are allowed.
9. Static, Anonymous Namespaces, and Linkage
- Do not use static outside a namespace.
- Do not use anonymous namespaces.
- Avoid global functions unless necessary.
10. Includes
- Never place using namespace or using std::... inside headers.
- Recommended include ordering:
1. Matching header
2. Standard library headers
3. External library headers
4. Local/project headers