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:

    • <string.h> for memset, memcpy and memmove

  • haiku/graphics.h vulkan backend uses the following libraries

  • 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.