... | @@ -20,6 +20,17 @@ The use of dynamic allocation can lead to heap fragmentation and out-of-memory e |
... | @@ -20,6 +20,17 @@ The use of dynamic allocation can lead to heap fragmentation and out-of-memory e |
|
Recursive code is hard to read and debug, and can easy lead to stack overflow errors.
|
|
Recursive code is hard to read and debug, and can easy lead to stack overflow errors.
|
|
- **Every class with a virtual function shall define a virtual destructor**
|
|
- **Every class with a virtual function shall define a virtual destructor**
|
|
Avoid undefined behavior where a derived class is destroyed through a reference to the base class, possibly leaking resources.
|
|
Avoid undefined behavior where a derived class is destroyed through a reference to the base class, possibly leaking resources.
|
|
|
|
- **Every header file shall be guarded using defines containing the full project path of the file**
|
|
|
|
Example: File `src/shared/sensors/ExampleSensor.h`
|
|
|
|
```
|
|
|
|
#ifndef SRC_SHARED_SENSORS_EXAMPLESENSOR_H
|
|
|
|
#define SRC_SHARED_SENSORS_EXAMPLESENSOR_H
|
|
|
|
|
|
|
|
//Code goes here
|
|
|
|
|
|
|
|
#endif /* SRC_SHARED_SENSORS_EXAMPLESENSOR_H */
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## **General rules**
|
|
## **General rules**
|
|
These are not critical rules, but you should follow them in most cases.
|
|
These are not critical rules, but you should follow them in most cases.
|
... | | ... | |