Skip to content

Commit

Permalink
Merge pull request #8 from prathameshd30/prathameshd30-update-readme
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
prathameshd30 authored Aug 14, 2024
2 parents 9d4507c + 43bbe1c commit c133ede
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
# Prime Headers
## Header-only, type-safe, generic data structures and algorithms for C.

### Testing
[![CMake + CTest on multiple platforms](https://github.com/prathameshd30/prime-headers/actions/workflows/cmake-multi-platform-val.yml/badge.svg)](https://github.com/prathameshd30/prime-headers/actions/workflows/cmake-multi-platform-val.yml)
[![CodeQL](https://github.com/prathameshd30/prime-headers/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/prathameshd30/prime-headers/actions/workflows/github-code-scanning/codeql)
[![Multiplatform CMake Build, CTest, Valgrind Profiling](https://github.com/prathameshd30/prime-headers/actions/workflows/cmake-multi-platform-val.yml/badge.svg)](https://github.com/prathameshd30/prime-headers/actions/workflows/cmake-multi-platform-val.yml)

Prime Headers is (aiming to be) a headers-only, easy to use, strongly typed way to use generic data structures and algorithms in C Projects.
Prime Headers is (aiming to be) a headers-only, easy to use, strongly typed way to use generic data structures and algorithms in C Projects. It is fairly primitive for ease of use.
It aims to have each data structure and algorithm thoroughly tested with primitive and pointer-to-structs examples.
It works primarily by ~~ab~~using the C preprocessor to a scale hitherto undreamt of (I have later realised that this scale was indeed dreamt to).

It aims to be completely tested, across platforms, and memory profiled.
It uses macros with arguments to generate the appropriate structs and functions at the preprocessing stage, leading to no runtime overhead. However, this approach has definite drawbacks, which are clarified further.

It works primarily by ~~ab~~using the C preprocessor to a scale hitherto undreamt of (I have later realised that this scale was indeed dreamt to).
### Features
- [x] Header-only, generic, type-safe data structures and algorithms.
- [x] Build tested on multiple platforms and compilers using CMake and GitHub actions.
- [x] Unit tested using CTest.
- [x] Memory profiled using Valgrind and CTest memcheck.
- [x] Supports primitives as well as pointer-to-structs.

### Currently Tested Platforms
- Windows
- cl (MSVC)

Initially, I was going to write it in the OOP C Pattern (pointers to functions inside structs), however as most people do not use the pattern, it would have hindered the usability of the framework. (Although it could be made in the future).
- Ubuntu
- gcc (GNU)
- clang (LLVM)

### To Do
- [x] Look into GitHub actions based testing
- [x] Valgrind testing?
- [x] How can I integrate CMake, CTest, GitHub actions and Valgrind?
- [ ] Write primitive as well as pointer-to-structs examples
- [ ] Examples should try to break the framework as much as possible
- [ ] Use constant pointers, pointers to constants and constant pointers to constant wherever applicable.
- [ ] Use constant pointers, pointers to constants and constant pointers to constant wherever applicable


### Checklist
- Each function, with pointer params, should check for NULL for each pointer,
### Checklist for each PR
- Each function, with pointer params, should check for NULL for each pointer.
- Have a thorough deletion mechanism for each data structure.
- Set unused pointers to return wherever applicable.
- Library functions in snake_case_##ANY_SUFFIX
- All reallocs need to be first assigned to temp variables
- Library functions in snake_case_##ANY_SUFFIX.
- All reallocs need to be first assigned to temp variables, so as to not lose access to data.

### Data structures and algorithms implemented

Expand Down Expand Up @@ -66,7 +74,6 @@ Initially, I was going to write it in the OOP C Pattern (pointers to functions i
- [ ] Merge Sort
- [ ] Quick sort


### Pros

1. Relatively easy use of generic data structures and algorithms while being type-safe.
Expand All @@ -76,11 +83,12 @@ Initially, I was going to write it in the OOP C Pattern (pointers to functions i

1. This method is optimised for ease of use (probably for beginners/learners because it primarily works with pointers to structs), however, defining multiple data structures in the same file may (read WILL) lead to **slower compilation times** due to large compilation units because of the coupling of interfaces (headers & prototypes) and the actual functionality (function definitions) itself.
2. **Poor support** (slow) for Intellisense and similar code intelligence and autocompletion tools.
3. As all the functions are defined in the macro, with everything being in C, there is no way to apply **access modifiers** to helper functions for a cleaner interface.

> This project is a side-effect of trying to develop a command-line tool for easier use of generic data structures for C, which splits the interface and the function definitions, leading to better compilation times.
## Some helpful projects which helped me develop this

1. Thought this was an original idea, but this repository I found later implemented this already - https://github.com/mystborn/GenericDataStructures

2. I got the idea for the need of type-safe data structures by seeing this repository, otherwise it is perfect, especially the error handling is **chef's kiss** - https://github.com/MostafaTwfiq/C-DataStructures-And-Algorithms
2. I got the idea for the need of type-safe data structures by seeing this repository, otherwise it is perfect, especially the error handling is **chef's kiss** - https://github.com/MostafaTwfiq/C-DataStructures-And-Algorithms

0 comments on commit c133ede

Please sign in to comment.