11# perfect-helloworld
22
3- A reference-grade C helloworld project.
3+ A _ (deliberately over-engineered) _ reference-grade C "Hello World" project.
44
5- Prints "Hello, World!" with maximal engineering discipline!
5+ This is what a modern, best practice-oriented C project might look like in 2026.
6+ The project is aimed at developers looking for a opinionated and modern starting
7+ point.
8+
9+ Feedback and constructive criticism are welcomed!
10+
11+ ## Non-goals
12+
13+ - Being the smallest or simplest C "Hello World" example
14+ - Avoiding modern tooling for portability
615
716## Features
817
9- - Meson build system;
10- - Cross-compilation support;
11- - Nix flake for dependency management;
12- - MIT license;
13- - GitHub Actions CI;
14- - Standard project structure (` docs/ ` , ` include/ ` , ` src/ ` , ` tests/ ` , ` scripts/ ` );
15- - Supports ` llvm-vs-code-extensions.vscode-clangd ` instead of ` ms-vscode.cpptools ` ;
16- - Doxygen support;
17- - Pkg-config (generates ` .pc ` file);
18- - Unit testing support via [ Unity] testing framework;
19- - Pre-commit hooks:
20- - ` clang-format `
21- - ` clang-tidy `
22- - ` meson format `
23- - ` nix flake check `
24- - ` nix fmt `
25- - [ IWYU]
26- - [ cppcheck]
27- - [ REUSE]
28- - Formatting JSON files with [ jq] ;
18+ - Meson build system
19+ - Cross-compilation support
20+ - Nix flake for dependency management
21+ - MIT license
22+ - GitHub Actions CI
23+ - Standard project structure (` docs/ ` , ` include/ ` , ` src/ ` , ` tests/ ` , ` scripts/ ` )
24+ - Uses ` llvm-vs-code-extensions.vscode-clangd ` instead of ` ms-vscode.cpptools `
25+ - Doxygen support
26+ - Pkg-config (generates ` .pc ` file)
27+ - Unit testing support via [ Unity] testing framework
28+
29+ ### Pre-commit hooks
30+
31+ The following checks are enforced via [ prek] (a lightweight alternative to
32+ [ pre-commit] ):
33+
34+ - ` clang-format `
35+ - ` clang-tidy `
36+ - ` meson format `
37+ - ` nix flake check `
38+ - ` nix fmt `
39+ - [ IWYU]
40+ - [ cppcheck]
41+ - [ REUSE]
42+ - [ jq] (for JSON formatting)
2943
3044## Getting started
3145
32- To setup your environment for developing this project run these commands:
46+ To set up your development environment, run the following commands:
3347
34481 . Install [ Nix] and [ direnv] .
35- 1 . Clone and cd into the repository .
49+ 1 . Clone the repository and cd into the project directory .
3650
3751 ``` bash
3852 git clone https://github.com/synalice/perfect-helloworld
@@ -74,16 +88,21 @@ To cross-compile the project, run this script:
7488` ` `
7589
7690> [! WARNING]\
77- > Invoking it for the first time make take some time, because Nix will download or
91+ > Invoking it for the first time may take some time, because Nix will download or
7892> build some parts of the cross toolchain.
7993
8094> [! TIP]\
81- > To cross-compile for different host architectures replace
95+ > To cross-compile for different host architectures, replace
8296> ` aarch64-multiplatform` with ` riscv64` or something else. [Read more
8397> here](https://nix.dev/tutorials/cross-compilation.html#choosing-the-host-platform-with-nix).
8498
8599> [! TIP]\
86- > To build dev or doc derivation (package) replace ` out` with ` dev` or ` doc` .
100+ > To build the ` dev` or ` doc` derivation, replace ` out` with ` dev` or ` doc` .
101+
102+ # # Known issues
103+
104+ - No cross-compilation in CI, as downloading cross toolchains from Nix binary
105+ caches significantly increases CI time.
87106
88107# # License
89108
@@ -92,8 +111,10 @@ This project is under the [MIT] license.
92111[jq]: https://jqlang.org/
93112[Nix]: https://nixos.org/download
94113[MIT]: https://opensource.org/license/mit
114+ [prek]: https://github.com/j178/prek
95115[IWYU]: https://include-what-you-use.org/
96116[Unity]: https://www.throwtheswitch.org/unity
97117[REUSE]: https://reuse.software/
98118[direnv]: https://direnv.net/# getting-started
99119[cppcheck]: https://en.wikipedia.org/wiki/Cppcheck
120+ [pre-commit]: https://pre-commit.com/
0 commit comments