Skip to content

About

Playing around with C

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

C Playground

Repo with multiple small projects as I play around with C and learn low-level programming and manual memory management.

NOTICE: These are learning projects for my own benefit, and the code here is not meant to represent any best practices in C or manual memory management. That said, feel free to take a peek and use as inspiration! :)

Projects

  • bean/: Small CLI tool that parses a subset of Beancount plain-text accounting
  • dodge/: Dodge the Blocks game using Raylib
  • particle/: Interactive particle simulation using Raylib
  • scratch/: Scratch project to try out various things that don't warrant their own project

The libs/ directory contains any shared libraries between projects:

  • libs/base/: Base utilities (arena and pool allocators, length-prefixed strings)

Dependencies

  • clang
  • clangd
  • clang-format
  • clang-tidy
  • cmake
  • task

On macOS:

xcode-select --install # libc

brew update
brew install llvm # clang, clangd, clang-format, clang-tidy
brew install cmake # to generate compile_commands.json for clangd
brew install go-task/tap/go-task # to run tasks in Taskfile.yaml

# use newer version of toolchain:
echo 'export PATH="$(brew --prefix)/opt/llvm/bin:$PATH"' >> ~/.zshrc
# for cmake to use newer version of compiler
echo 'export CC=clang' >> ~/.zshrc
echo 'export CXX=clang++' >> ~/.zshrc

The source code in this repository was last tested to build, lint, and pass tests with the following environment and toolchain (printed using print_macos_env.sh):

macOS                  26.7.2
Architecture           arm64
Clang                  23.1.4
clang-tidy             23.1.4
clang-format           23.1.4
clangd                 23.1.4
CMake                  4.4.4
Command Line Tools     26.6.0.0.1781586589
Apple ld               1267
macOS SDK              26.5

Development

Run CMake configuration step (and generate compile_commands.json for clangd):

task configure

Build all projects:

task build

Format using clang-format:

task format

Lint using clang-tidy:

task lint

Run tests:

task test

For all available commands see Taskfile.yaml or run task in the terminal.

Conventions

See STYLE.md for C style conventions used in this repo.

AI disclaimer

I used AI in "teacher/tutor" mode to give me hints or review my code. It was explicitly instructed not to write code for me or give me answers (that would defeat the point of learning!).

AI was used to generate non-source code files (ex: CMake configuration files, data sample files, etc.), but every single line of C was (painstakingly) written by yours truly :)

Credits

Game assets (sound, art) from Kenny.

About

Playing around with C

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages