This commit is contained in:
Miloslav Ciz 2024-06-29 19:04:58 +02:00
parent 681319f2f2
commit f5c9f4da18
39 changed files with 1862 additions and 1803 deletions

View file

@ -107,6 +107,7 @@ if (c < d)
- **Try to not create many source files**, many times your project can very well be in a single file which is the ideal case -- it will make it compile VERY fast, possibly be even better optimized (the compiler sees the whole code) and it will be easy to compile, it's basically a win-win-win-win-win-win-win scenario. Create **[header only libraries](header_only.md)** If you have multiple files, keep them in the same directory and try to have just a **[single compilation unit](single_compilation_unit.md)** (only one .c file with several .h files). Try to make files no longer than 10k lines.
- **Use the LRS [version numbering](version_numbering.md) system**.
- **Never use non-[ASCII](ascii.md) characters in your source code**. Just don't, there is basically never any need for it.
- **Don't depend on any compiler extensions!** For maximum portability minimize [dependencies](dependency.md), i.e. don't RELY on things like GNU C extensions, POSIX extensions (things like `_POSIX_C_SOURCE`, `_XOPEN_SOURCE` etc.). You MAY use them, but always do so in a way that makes it easy to get rid of them -- for example do not use macros such as `PATH_MAX` directly, always define your own macro, e.g. `#define MYLIB_PATH_MAX PATH_MAX` and only use that -- this way you may easily switch to e.g. hardcoded limit if the macro isn't available on some system. Similarly with anything else: if your program is using a feature specific to a compiler, operating system, some extra third party standard and so on, always offer an easy way of disabling or replacing it ([preprocessor](preprocessor.md) is very good for this).
- ...
### Example