From 37c1f93902e944e6c61d45a4b226833328e53a98 Mon Sep 17 00:00:00 2001 From: Ellen Arvidsson Date: Sat, 28 Jun 2025 01:08:29 +0200 Subject: [PATCH] updated with some code style and build instructions --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d01411..0aa5d85 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,70 @@ experimental type system implementation ## getting and building +This will get you a basic build configured for development and debugging in the +subdirectory `build-debug/` of repository base: ```sh git clone https://gitta.log-e.se/lnsol/log-e-sappho.git cd ./log-e-sappho -cmake . -B build -cd build +cmake . --preset=debug +cd build-debug make ``` +To get sane error messages from editors using `clangd` for diagnostics, i.e. +using the same compilation flags configured for the build by cmake, in the repo +base directory link `compile_commands.json`: +```sh +ln -s build-debug/compile_commands.json +``` + +## "Code style" + +I learned C from a guy that used to hack on OpenBSD, and just got used to +writing it this way. If you wanna hack on this yourself, use your judgement. +Look at the rest of the code and make yours look similar. Like, who cares about +rules really? Here are some guidelines tho. + +**80 columns text width.** + +Use **8 spaces wide TABS** (yes, actual TABS, not just 8 spaces) for +indentation and when inside `while`-/`if`-/etc. **conditions that span multiple +lines, indent 4 spaces + 0 or more TABS**, as to separate condition from body +of + +I.e. do +```c +if (1 /* this is a very long condition */ + == 2 /* spanning multiple lines */ + || 2 < 3 /* and we indent like this) { + this = the_way; + /* as to increase distinguishability of condition from body */ +} +``` +not +```c +if ( /* ... */ + 2 < 3) { + eyes = bleeding; +} +``` + +Conditional statements without `{ .. }` is okay (preferred) if the condition +fits on one line. + +I.e. do +```c +if (1 /* short condition that fits on one line */) + u = the_best; +``` +and +```c +if (the_variable_that_has_that_long_name = function_with_a_long_name_too( + arg_is_shorter_tho)) { + gesture = clapping; +} +``` + ## repository content This repository contains: