This library provides Core Functionality built upon the C language. Inspired and taken from Modern Languages such as Python, Rust etc.
- Memory Management: Allocators, Memory Debugger.
- Types & Data Structures: Clean Systematic Data types and Structures with feature-full fuctionality.
- Meta-Programming: An absolute abuse of C-preprocessor.
- Utilities: Mini Libraries and modules for extendend fucntionality (e.g. TUI) and wrappers (e.g. curl, cglm)
List of sub-modules of provided by the library.
Sub-module | Description |
---|---|
Data Types | |
arr.h | Implementation of Generic Dyanmic Array |
arrfree.h | Implementation of auto free for Dyanmic array type |
arrllist.h | Implementation of Array Allocated Generic Linked List |
autotype.h | Autotype alias. |
atomic.h | Custom atomic wrapper. |
bytes.h | Implementation of byte array |
dynt.h | Implementation of Opaque Array |
enum.h | Implementation of Sum Type |
fnptr.h | Function pointer macro |
hashset.h | Implementation of Generic Hash List/Map/Table |
hashstr.h | Implementation of String Key, Hash Set. |
irrg.h | Implementation of Opaque List |
map.h | Multi-layer tilemap. |
map2d.h | Single-layer tilemap. |
map3d.h | 3-Dimentional tilemap. |
mapch.h | Multi Chunk 3D tilemap |
matrix.h | Matrix Type |
llist.h | Implementation of Linked List |
obj.h | Closure & V-Tables |
option.h | Implementation of Option Sum Type |
pairarr.h | Implementation of Pair Array |
record.h | Struct Gen that can be used by c macros, Record. |
result.h | Result Type |
return.h | Function return definitions |
soarr.h | Implementation of Struct of Arrays |
string.h | Implementation of Byte String (ASCII). |
string8.h | Implementation of utf-8 compactible String. |
tree.h | m-ary tree Implentation |
tuple.h | Implementation of Tuple Type. |
u8arr.h | u8 array |
vector.h | Vector Type |
RNG | |
random.h | PRNG & Hash Functions |
Processing | |
omp.h | OpenMP wrapper |
subp.h | Spawing a sub-process/child process |
thread.h | Thread Wrapper around pthread |
File IO | |
fio.h | File IO |
Terminal IO | |
ansifmt.h | ANSI Terminal string format. |
print.h | Print Implentation |
tui.h | Terminal based UI, lightweight alternative to ncurses. |
termio.h | Terminal io functions |
tgprint.h | Type Generic Print |
Web & Networking | |
curl.h | Wrapper around curl |
htmlfmt.h | Format Macro for html |
System | |
sys.h | Functions for comunicating with system. |
time.h | Time based functionality |
Utilities | |
bnf.h | Context free grammer notation Backus-Naur form |
bitf.h | Macros for bit field manupilation |
cglm.h | Wrapper for cglm |
contof.h | Container of macro |
utf8.h | utf-8 functions |
utils.h | Utility macro and functions |
lexer.h | Generic Lexer |
offsetof.h | Custom Offset macro. |
strto.h | Do a type generic sscanf |
scene.h | Scene Director for apps and games |
serial.h | Serializer |
Design | |
argparse.h | Parse list of arguments of a program. |
assert.h | Custom assert implementation. |
forrange.h | For-range for different data types |
gmath.h | Math functions for vectors and matrix |
test.h | Test Suite Impletation |
type.h | Define a Type Set |
typeid.h | List of Type-ids generated from typegen.h |
typeof.h | typeof macro |
typegen.h | Macro for generating type info |
Meta-programming using C-preprocessor. Explore Source
Sub-Module | Description |
---|---|
prep/args.h | Macro for passed-in arguments. |
prep/base.h | Basic Utility Macros |
prep/call.h | Function Call Wrapper |
prep/eval.h | Eval Macro |
prep/loop.h | Macro for compile-time loop |
prep/map.h | Map Macro |
prep/num.h | Macro for compile time small number arithmatic and comparism |
prep/nm/assert.h | Assert Constructors |
prep/nm/cond.h | Condtional Statement, doif Constructors. |
prep/nm/ident.h | Temporary Identifier Name Generator |
prep/nm/pragma.h | Inline Compiler Pragma |
prep/nm/string.h | Meta-String Functions |
Helper function for preprocessor macros, not used directly
Name | Description |
---|---|
prep/comp/eval.h | Token Exaustor |
prep/gen/args/applyfxy.h | Dual parameter functor |
prep/gen/args/get.h | Parameter fetch |
prep/gen/args/getupto.h | Parameter List fetch |
prep/gen/args/skip.h | Parameter Ignore |
prep/gen/args/var.h | Parameter Vardic Count |
prep/gen/num/dec_u8.h | |
prep/gen/num/dec_n1024.h | |
prep/gen/num/dec_n2048.h | |
prep/gen/num/inc_u8.h | |
prep/gen/num/inc_n1024.h | |
prep/gen/num/inc_n2048.h |
Stuff that is probably needed everywhere.
Sub-Module | Description |
---|---|
std/alloc.h | Allocator |
std/arch.h | Macro for defining Architecture |
std/io.h | IO Functions |
std/mem.h | Memory Function |
std/primitives.h | Primitives |
z_
is made with modularity in mind so many parts of it are as self-isolated as they can,
it doesn't even include standard library except stddef.h
, stdint.h
and stdbool.h
for type
declaration but they still require the bare minimum base
for to be working properly such
as, z_/arr.h
can be included in itself but it still require base.h
of types
for z__u32
and mem.h
for memory allocation definitions.
Therefore, You need to explicitly include the <stdlib.h>
, <string.h>
.
Inorder to integrated z_
in your project only
git clone --depth=1 git://github.com/zakarouf/z_.git
sh build.sh lib
Will result headers at ./build/include
as z_
directory.
Copy the z_
folder onto your include
directory and we are good to go.
#include <z_/z_.h>
Run the build.sh
script, with the following parameters
sh build.sh install lib
By Default, the path for Headers is usr/local/include/z_
, you can change it by editing the
build.sh
file itself, INCLUDE_DIR
to be specfic.
z_
is now uses stb-style header impletation macro without compiling a .a
library to link to.
Define Z__IMPLEMENTATION
in any one of the source file before including the header.
I would recommended creating a seperate empty source file with all the impletation defined.
#define Z__IMPLEMENTATION
#include <z_/time.h>
Overview on the library
Additional syntax Highlighting for types and such are include in the extra/c.vim.
To add it into your project, either copy the contents of the c.vim
file or put
c.vim
into your after/syntax
folder, such as ~/.config/vim/after/syntax/
directory.
This will load on top of your syntax highlighting for every .c file.
z_
had a humble beginning as a single header for defining primitive types in ztorg project.
Later on I added more quality of life stuff such as Type-Generic Dyanmic Arrays etc. It was then I decided to move its development to a separate repo with more than just a "Data Type Library". I wanted to created a core, standard-library that I can just use anywhere as a starting point.
Linux and MacOS is fully supported while, with Windows your mileage might vary.
As for Compiler GCC or Clang is recommended.
Bloat. Creating such library that I can use anywhere, I wanted to have as less bloated binary wise as posible, while also having to combat the non-type generic nature of the C language.
If by any case, I dont want use a bare macro. I would wrap it up inside of a function.
#define my_macro_function(a, b) { ... }
void my_function(int a, int b)
{
my_macro_function(a, b);
}
Me. Or you if you stumble upon my stuff and found it cool. But as of writing, I created this for myself. This repo is so I can easily maintain and access the code and or share it with my friends. I am not a good Programmer by a long shot, I just like when my computer goes beep-boop.
It takes many features from other libraries and projects. Whilst also some Reffrences and books.
Hirrolot's Datatype99. For my own implementation of Sum Types. The actual impletation is dis-similar to them. My implementation of z__Enum is no where near as elegant as Datatype99.
Awesome C Preprocessor Helped to study on the C's magical Preprocessor.
This library is not perfect and I know there are many others like it, but this one is mine <3.