You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide should be treated as a fundamental reference when working on our codebase.
23
-
24
-
## Core Principles
3
+
**IMPORTANT: Pound's C++ codebase is written in a C-style, intentionally avoiding C++ features except for namespaces. The goal is to hopefully make the codebase easy to follow, understand, and debug for new developers wanting to contribute.**
25
4
26
5
### 1. Performance First
27
6
28
7
Performance is the top priority in all aspects of development. Always ask yourself: "Is the CPU wasting cycles running
29
-
this code? If so, how do I fix it?" The data-oriented design resource above contains answers to these questions.
8
+
this code? If so, how do I fix it?".
30
9
31
10
### 2. Memory Management
32
11
33
-
-**Heap Allocation Ban**: Using memory allocation functions like malloc(), free(), new, and delete is prohibited.
34
-
-**Stack Preference**: Keep everything on the stack whenever possible.
35
-
-**Last Resort**: If you must allocate memory, use our custom memory allocator in `core/memory/arena.h`. This should be
36
-
your last resort only.
37
-
38
-
The reason for these strict rules is that heap allocations can introduce undefined behavior issues into our codebase.
12
+
-**Heap Allocation Functions Ban**: Using memory allocation functions like malloc(), free(), new, and delete is prohibited. Use our custom memory allocator in `src/host/memory/arena.h`. Allocating memory should only be done in `main.cpp` during initialization, otherwise your code will be rejected.
39
13
40
14
### 3. Safety First
41
15
42
-
1.**Error Handling**: Every return code from a function must be checked and handled appropriately.
43
-
2.**Assertions**: Use assertions to guarantee behavior whenever possible. Watch this video for an explanation:
16
+
1.**Barr C**: See the Barr C Style Guide PDF file in the root directory for making Pound's code as safe as possible.
17
+
2.**Error Handling**: Every return code from a function must be checked and handled appropriately.
18
+
3.**Assertions**: Use assertions to guarantee behavior whenever possible. Watch this video for an explanation:
44
19
https://youtube.com/shorts/M-VU0fLjIUU
45
-
3.**Static Analysis**: Use the SonarQube static analyzer to catch potential bugs early in development.
20
+
4.**Static Analysis**: Use the SonarQube static analyzer to catch potential bugs early in development.
46
21
47
22
### 4. Documentation
48
23
@@ -51,7 +26,7 @@ by current and future programmers working on this project.
51
26
52
27
## Style Conventions
53
28
54
-
Refer to `main.cpp` and the kvm folder for examples of proper code styling. Here are some specific rules:
29
+
See the Barr C style guide for reference. Use clang-format at the root directory to create Barr C compliant code. Here are some non Barr C specific rules:
55
30
56
31
1.**Constant First in Equality Tests**:
57
32
```c
@@ -63,19 +38,3 @@ Refer to `main.cpp` and the kvm folder for examples of proper code styling. Here
63
38
if (constant == var)
64
39
if (NULL == pointer)
65
40
```
66
-
2.**Todo Comments**: Use the following format:
67
-
```c
68
-
// Todo(<Username>:<section>): ...
69
-
70
-
Where <section> is one of:
71
-
72
-
- cpu
73
-
- gpu
74
-
- gui
75
-
- memory
76
-
- filesystem
77
-
78
-
For example:
79
-
// Todo(GloriousTaco:memory): Create a custom allocator.
0 commit comments