Created
February 24, 2026 10:55
-
-
Save ABD-01/987f39d78291d03310af281ccf6f98a6 to your computer and use it in GitHub Desktop.
Coding Guidelines using clang-tidy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Checks: > | |
| -*, | |
| readability-identifier-naming, | |
| readability-identifier-length | |
| WarningsAsErrors: '*' | |
| CheckOptions: | |
| - key: readability-identifier-naming.VariableCase | |
| value: lower_case | |
| # Global variables must have g_ prefix, enforced as snake_case with prefix "g_" | |
| - key: readability-identifier-naming.GlobalVariableCase | |
| value: lower_case | |
| - key: readability-identifier-naming.GlobalVariablePrefix | |
| value: g_ | |
| # Macros: ALL UPPERCASE with underscores | |
| - key: readability-identifier-naming.MacroDefinitionCase | |
| value: UPPER_CASE | |
| # Enums: UPPERCASE | |
| - key: readability-identifier-naming.EnumConstantCase | |
| value: UPPER_CASE | |
| # Variable Lenght | |
| - key: readability-identifier-length.MinimumVariableNameLength | |
| value: 4 | |
| - key: readability-identifier-length.MinimumParameterNameLength | |
| value: 4 | |
| - key: readability-identifier-length.MinimumLoopCounterNameLength | |
| value: 1 | |
| - key: readability-identifier-length.IgnoredLoopCounterNames | |
| value: '^[ijkxyz]$' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define MAX 100 | |
| #define VALUE 200 | |
| int x=1; | |
| int y =2; | |
| int z = 3; | |
| int foo(){int a=1; if(a<10){printf("Short block no newline\n");} if(a>0) { printf("Bad brace style\n"); }else{printf("Else on same line\n"); } return a;} | |
| template <typename T>class Example{public: T data;Example(T d):data(d){}}; | |
| int main(){for(int i=0;i<MAX;i++){ if(i%2==0) printf("Even\n"); else printf("Odd\n"); }return 0;} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define MAX_BUFFER 256 // GOOD | |
| #define maxBuffer 256 // BAD | |
| // Global variables | |
| int g_counter = 0; // GOOD | |
| int counter = 0; // BAD | |
| int fuel_sensor_value; | |
| // Enums | |
| enum COLOR { RED, GREEN, BLUE }; // GOOD | |
| enum Color { Red, Green, Blue }; // BAD | |
| // Function with parameters | |
| void process_data(int size_val, int data_len) { // GOOD | |
| int idx_val = 0; // GOOD | |
| int ab = 1; // BAD (too short) | |
| for (int i = 0; i < size_val; i++) { } // GOOD | |
| for (int q = 0; q < data_len; q++) { } // BAD | |
| int count = 0; // GOOD | |
| int I = 2; // BAD | |
| int camelCaseVar = 3; // BAD (camelCase not allowed) | |
| int snake_case_var = 4; // GOOD | |
| } | |
| void foo(int x) { // BAD (x too short) | |
| printf("%d\n", x); | |
| } | |
| // Future use cases | |
| // TODO: Constant naming: k_ prefix) | |
| const int k_max_speed = 100; // GOOD | |
| const int speed = 50; // BAD | |
| // TODO: Struct members (common embedded convention: m_ prefix) | |
| struct Example { | |
| int m_id; // GOOD | |
| int value; // BAD | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment