# Coding Style and Conventions **haiku** is primarly developed in C99 and C++17 (for libraries C++ implementations as in VMA) ## Coding style: - modules are prefixed by `hk` - struct names are prefixed by `hk_modulename_` (ex: `hk_gfx_`) - function are prefixed by `hkmodulename_` (ex: `hkgfx_`) - struct names and functions are in `snake_case_style` - struct names are suffixed by `_s` and typedefs are suffixed by `_t` - enumerations names and typedefs are suffixed by `_e` - enumerations items are written in `UPPERCASE` and prefixed by `HK_` - macros definitions are always written in `UPPERCASE_SCREAMING_STYLE` - Description structures used for object creation are suffixed by `_desc` - Structures used as function parameters/arguments are suffixed by `_params` ## Implementation choices: - **haiku** requires user to provide his own allocations, assertions and logging mechanisms: * `hk_user_assert_t`: a user-defined assertions (`assert` and an optional user context) * `hk_user_logger_t`: a user-defined logging (`log` and an optional user context) * `hk_user_memory_allocator_t`: a user-defined memory allocations (`alloc`/`free`/`realloc` and an optional user context) - **haiku** C implementation uses: * `` for `memset`, `memcpy` and `memmove` - **haiku/graphics.h** **vulkan** backend uses the following libraries * [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) (as submodule) under MIT License * [Vulkan-Headers](https://github.com/KhronosGroup/Vulkan-Headers) (as submodule) dual-licensed under MIT or Apache-2.0 * [volk](https://github.com/zeux/volk) (as submodule) licensed under MIT - **haiku/application.h** backend requires one of the following libraries * [GLFW](https://github.com/glfw/glfw) under Zlib License * future html/emscripten implementation ? * maybe a future SDL implementation ? **haiku** C99 code base does not use `` nor `` standard headers. ## Useful links and references - [Modern C for C++ peeps](https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html) by Andre Weissflog - [Automatic Language Bindings](https://floooh.github.io/2020/08/23/sokol-bindgen.html) by Andre Weissflog - [So you want custom allocator support in your C lirabry](https://nullprogram.com/blog/2023/12/17/) by Chris Wellons - [An Opinionated Post on Modern Rendering Abstraction Layers](https://alextardif.com/RenderingAbstractionLayers.html) by Alex Tardif - [Resource State Management](diligentgraphics.com/2018/12/09/resource-state-management/) by Diligent Graphics