Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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
  • 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, lldb, 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

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

Watchers

Forks

Releases

Packages

Contributors

Languages