Haikal uses metaprogramming to generate C code as a pre-build step.
Haikal monomorphises C files and writes them to be included.
Code should be easy to debug & works great with LSPs.
- Add
haikal
as a git submodule to your project and build the program. - Add
haikal.toml
to your project root. - example: c-init
- To generate the files to
metapath
, build and invoke thehaikal
program from the your root directory. - To generate custom types, add a
//haikal@container:type
in your code & simply include the headers. #include <hkArray.h>
to include all generatedhkArray
types.
The i32
in this instance could be any data type:
//haikal@hkArray:i32
hkArray_i32 array = hkarray_i32_create(12);
array.data[0] = 0x19;
hkarray_i32_destroy(&array);
Haikal uses toml for configuration. For example:
[core]
metapath = "extern/haikal/src/meta/" # where to generate files to
- hkArray: growable heap allocated array.
- hkList/hkNode: singly linked list.
- hkDList/hkBiNode: doubly linked list.
- hkStack/hkNode: stack.
- hkQueue: queue
Cannot add pointer types to [meta]
unless typedef
ed. Could automate the process by detecting the pointer and auto typedef
ing it.
For example: int *
will become typedef int *intptr
and then you can generate hkArray_intptr
.