content
1. formatting & layout
- indentation: 2 spaces (no tabs)
- line length: max 80 characters
- whitespace: no trailing whitespace allowed
- brackets: K&R style (opening bracket on the same line)
2. naming conventions
- style:
snake_case for functions, variables, and structures
- macros:
UPPER_CASE for macros
- config macros:
CONFIG_UPPER_CASE in config.h with prefix CONFIG_
- pointers:
char* func(...) for types, const char *str for variables
3. function design
- keep functions small (50-75 lines max) and single-purpose
- max 3 levels of nesting (split into helpers if deeper)
4. comments & headers
- write in English, lowercase, no trailing dot (except copyright notices)
- explain why, not what
- use standard C-style comments (
/* ... */)
- use include guards in lowercase for header files (e.g.,
#ifndef DIR_FILENAME_H
#define DIR_FILENAME_H
#endif /* DIR_FILENAME_H */)
- keep header files minimal: max 4 headers (
fns.h, dat.h, project header, config.h)
5. dependencies & build
- dependencies: max 1-2 external dependencies; write custom code if non-essential
- allowed defaults: gcc, make, X11, libc, mk
- shell scripts: use
#!/bin/sh and snake_case naming
- build tool: mkfile from repository
- languages: C, GASM, NASM
6. required files
README and LICENSE in plain text format
mkfile
example
/*
* main.c — entry point example
*/
#define SYS_write 1
#define STDOUT 1
static long write(int fd, const void *buf, unsigned long count) {
long ret;
asm volatile (
"syscall"
: "=a"(ret)
: "a"(SYS_write), "D"(fd), "S"(buf), "d"(count)
: "rcx", "r11", "memory"
);
return ret;
}
int main(int argc, char *argv[]) {
write(STDOUT, "hello world\n", 12);
return 0;
}
- committing changes:
git commit -m "feature: add lexer"
- generate patch:
git format-patch --subject-prefix="REPO-NAME PATCH" -1 HEAD
- send email:
git send-email --to="evenfri256@gmail.com" 0001-feature-add-lexer.patch