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 byHK_
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:
<string.h>
formemset
,memcpy
andmemmove
haiku/graphics.h vulkan backend uses the following libraries
VulkanMemoryAllocator (as submodule) under MIT License
Vulkan-Headers (as submodule) dual-licensed under MIT or Apache-2.0
volk (as submodule) licensed under MIT
haiku/application.h backend requires one of the following libraries
GLFW under Zlib License
future html/emscripten implementation ?
maybe a future SDL implementation ?
haiku C99 code base does not use <stdio.h>
nor <stdlib.h>
standard headers.
Useful links and references¶
Modern C for C++ peeps by Andre Weissflog
Automatic Language Bindings by Andre Weissflog
So you want custom allocator support in your C lirabry by Chris Wellons
An Opinionated Post on Modern Rendering Abstraction Layers by Alex Tardif
Resource State Management by Diligent Graphics