From ce8debc03d2ed291285535462cbf4411bf298278 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 7 Nov 2024 12:28:39 +0100 Subject: update contributing.md --- contributing.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/contributing.md b/contributing.md index c7f836e..ba8ad68 100644 --- a/contributing.md +++ b/contributing.md @@ -78,8 +78,8 @@ that you can click on to open them. } ``` -- Header includes are split into paragraphs separated by a blank line. The - order is: +- Header includes (at the top of files) are split into paragraphs separated by + a blank line. The order is: 1. system headers (using `<`brackets`>`) 2. relative headers NOT in the same folder as the current file 3. relative headers in the same folder as the current file @@ -111,6 +111,52 @@ that you can click on to open them. #include "api/Sprite.h" ``` +-
+ If there is one, the matching template header (.hpp) is included + at the bottom of the regular header (.h) +
GoodBad
+ + Foo.h: + ```cpp + #pragma once + + template + void foo(); + + #include "Foo.hpp" + ``` + + Foo.hpp: + ```cpp + #pragma once + #include "Foo.h" + + template + void foo() { + // ... + } + ``` + + + Foo.h: + ```cpp + #pragma once + + template + void foo(); + ``` + + Foo.hpp: + ```cpp + #pragma once + #include "Foo.h" + + template + void foo() { + // ... + } + ``` +
-
using namespace may not be used in header files (.h, .hpp), only in source files (.cpp). @@ -546,7 +592,7 @@ that you can click on to open them.
GoodBad
```cpp - std::unique_ptr foo = std::make_unique(); + auto foo = std::make_unique(); ``` @@ -557,22 +603,23 @@ that you can click on to open them. ```
-
- Do not use malloc, calloc, or free (instead use new and delete) + Do not use C-style memory management APIs (malloc, + calloc, free)
GoodBad
```cpp - Foo* foo = new Foo(); + Foo * foo = new Foo(); delete foo; ``` ```cpp - Foo* foo = (Foo*)malloc(sizeof(Foo)); + Foo * foo = (Foo *) malloc(sizeof(Foo)); free(foo); ```
-
- Prefix member variables with this-> + Prefix all class members with this->
GoodBad
```cpp @@ -583,8 +630,8 @@ that you can click on to open them. ```cpp - void Foo::set_value(int value) { - value = value; + void Foo::set_value(int new_value) { + value = new_value; } ```
-- cgit v1.2.3