From 35956dc13e2854b96abbfc636ce3f4a6ce7f0749 Mon Sep 17 00:00:00 2001 From: Adam <45126464+KeyZox71@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:00:30 +0100 Subject: [PATCH] Update NORM.md --- NORM.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/NORM.md b/NORM.md index e22479e..1692f68 100644 --- a/NORM.md +++ b/NORM.md @@ -73,3 +73,43 @@ void example() { } } ``` +## Using _t Suffix for typedef +The _t suffix is a convention to indicate a type definition or alias. It helps distinguish custom types from standard or built-in types. \ +Use _t consistently for all user-defined types created with typedef or using. \ +Guidelines: +- Descriptive Names: + - The base name should clearly describe the type's purpose. + - Add _t to the end of the name for clarity. + - Example: + ```cpp + typedef unsigned int uint_t; // Alias for unsigned int + ``` +- Consistency Across Codebase: + - Always use _t for typedefs to maintain consistency and readability. + - Example: + ```cpp + typedef struct { + int id; + char name[50]; + } student_t; + ``` +Examples: +- Basic Alias: +```cpp +typedef double distance_t; +distance_t radius = 5.5; +``` +- Pointer Alias: +```cpp +typedef char* string_t; +string_t greeting = "Hello, World!"; +``` +- Struct Alias: +```cpp +typedef struct { + int x; + int y; +} point_t; + +point_t p1 = {10, 20}; +```