- Notifications
You must be signed in to change notification settings - Fork0
An Easy-to-use Framework for the C Language.
License
zakarouf/z_
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This library provides Core Functionality built upon the C language. Inspired and taken from Modern Languages such as Python, Rust etc.
- Memory Management. Minimal Memory Tracker for logging memory, Autofree that can act as a build-in deconstructor.
- Type & Data Structures. Clean Systematic Data types and Structures with feature-full fuctionality.
- Meta-Programming. An absolute abuse of C-preprocessor.
- Multi-Threading. A more elegant way to handle concurrency.
- Standard Functions. Did you wanted stuff like logging, better File IO, Generic Printing, Error Handling similar to try catch. Yes we got those.
A simple memory wrapper for debug purpose.
- A wrapper around malloc, calloc, realloc, free. z__MALLOC, z__CALLOC, z__REALLOC, z__FREE.
- Logging memory allocation and de-allocation that can output in any file-stream including stdout.
- Evaluation of Total allocation and free, helps to combat memory leaks and such
Types to allow more stable/systamatic programming procedure with type-safe generic Data-types and Data-Structures, say no more to "Implement this basic functionaity 10 different ways in 10 different programs". Whilst some types are compatible with other libraries too!
Vectors and Matrix in particular are totally compatible with thecglm library.
- Primitive Types
- Type System &Typesets
- Algebraic Data Type
- String
- String List
- String List Array
- Arrays
- Vector Types
- Matrices
- Linked List
Meta-programming using C-preprocessor.Source Code
Multi-Threading wrapper arrund both OpenMP and Pthread with C11<threads.h>
considered for the future.
The Development has started with OpenMP.
Pthreads impletation has also started with itsbase.
Benchmark Report of the performance achieved with OpenMP, Pthread compared to its single threaded counter-part is in the works.
Currently I'm using Macbook Air 2012-mid with 4 Threads for the benchmark.
- 2D 10000x10000 Terain Map Generation with Perlin Noise.64% Faster.Source code
Lastlyz_
Also Provides Basic day-to-day set of functions revolving around Time, File IO, System, Logging and many more.
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 exceptstddef.h
,stdint.h
andstdbool.h
for typedeclarationbut they still require the bare minimumbase
for to be working properly suchas,z_/types/arr.h
can be included in itself but it still requirebase.h
oftypes
forz__u32
andmem.h
for memory allocation definitions.
Therefore, You need to explicitly include the<stdlib.h>
,<string.h>
.
Inorder to integratedz_
in your project only
git clone --depth=1 git://github.com/zakarouf/z_.gitsh build.sh lib
Will result a library libz_.a created in the./build/lib
and headers at./build/include
asz_
directory.
Copy thez_
folder onto yourinclude
directory. And copy thelibz_.a
to thelib
directory and link it against the executable and we are good to go.
#include<z_/z_.h>
Run thebuild.sh
script, with the following parameters
sh build.sh install lib
By Default, the path for Headers isusr/local/include/z_
and for library it islibz_.a
, you can change it by editing thebuild.sh
file itself,LIB_DIR
andINCLUDE_DIR
to be specfic.
Inside the source directoryconfig_{MODULE}.h
that can be modified by the user in-order to change the behaviour, include, exclude the fuctionality of that sub-library.
{MODULE} is the name of the Module i.e. config_imp.h, config_prep.h etc.
Such as inside ofsrc/lib/_config_types.h
#defineZ___TYPE_CONFIG__USE_TYPE_LINKEDLIST
This particular config tells to include the Linked List type and its functionaity at core; whenz_.h
is included, and if we comment out it
//#define Z___TYPE_CONFIG__USE_TYPE_LINKEDLIST
Will result in a errorThis forces to you to include linked list type manually.
#include<z_/types/llist.h>
Now this will work as it should.
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 thec.vim
file or putc.vim
into yourafter/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 inztorg 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.
#definemy_macro_function(a,b) { ... }voidmy_function(inta,intb){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'sDatatype99. For my own implementation of Sum Types. The actual impletation is dis-similar to them. My implementation ofz__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.
About
An Easy-to-use Framework for the C Language.