statulr/aurc

Consistency

Closed this issue · 4 comments

Hi I'm from @cloudzydev's stream.

One recommendation i can make you are using both camel case and snake case at the same time
interchangebly. Since you're writing for UNIX.
I suggest: Types are PascalCase Enums are UPPER_SNAKE
Variables are snake_case Functions are snake_case Also you use the Windows Format
for brackets not unix or gnu.

You can use formatters in Neovim:
Clang Format Options

Kernel Practices

Here is some example I made:

#pragma once

#include <stdheaders.h>

#include "yourheaders.h"

#define SOME_MACRO 5
const int SOME_CONST = 2;

enum {
    ENUM_T1,
    ENUM_T2,
} ENUM_TYPES;

// example code
struct MyType {
    int inner_field;
    union {
        /* */
    };
};

// Use namespaces on functions to prevent collision
void ns_printf(const char* fmt, void** args);

extern char* some_variable;

void ns_printf(const char* fmt, void** args)
{
    while (true) {
        if (false) {
        }
    }
}

It would make more sense to follow the POSIX convention instead, which is all snake_case, but if it's a type, then it has a suffix _t, this could be extended to be more specific like _e for enum or _s for struct

It would make more sense to follow the POSIX convention instead, which is all snake_case, but if it's a type, then it has a suffix _t, this could be extended to be more specific like _e for enum or _s for struct

Using snakecase then?

I personally use CamelCase for all things that are types; for structs, enums and unions, I also prefix a _. When it comes to functions and variables, I use snake_case. You can really make the style whatever you like but consistency is important.

I personally use CamelCase for all things that are types; for structs, enums and unions, I also prefix a _. When it comes to functions and variables, I use snake_case. You can really make the style whatever you like but consistency is important.

k