# Docs This file is meant to explain how it's working. I'll try to keep it up to date. ## General idea Meta programming is really useful, in a lots of ways, that's why I'm trying to implement this in C, in the most pleasant way. Header-only libraries are also a must imo, so let's try to implement meta programming within a single header! The same header for both compilation and runtime btw. ## Compilation time `cmeta.h` contains the code to parse structs, lexing is handled by `stb_c_lexer` (for now). The `bool process_file(const char *file_path)` function calls `gcc -E ` (so we handle macros etc), then parses the result. It then generates all `Struct_Info`s in a special place in the header, delimited by two `// AUTO GENERATED CODE //`. If anything has failed, nothing will be generated between the two comments, so cmeta remains intact. This struct: ```c typedef struct { int int_field; } Foo_Struct; ``` Will be converted to this: ```c // cmeta.h // AUTO GENERATED CODE // static Struct_Info foo_struct_info = { .name = "Foo_Struct", .fields_count = 1, .fields = (Field_Info[1]) { { .type = "int", .name = "int_field" }, }, }; // AUTO GENERATED CODE // ``` ## Runtime `cmeta.h` now contains both type infos and useful functions to interact with them.