From f90934f78c9511f02f6e285505dd511c38de8411 Mon Sep 17 00:00:00 2001 From: Spencer Conlon Date: Tue, 24 Dec 2024 05:42:19 +0000 Subject: [PATCH] Add README.md --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9c2e65 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# GCML + +![C/C++ Utility Macros](https://img.shields.io/badge/C%2FC++-Utilitys-blue.svg) + +A comprehensive collection of essential C and C++ utility macros designed to streamline your development workflow. Enhance your code with powerful tools for debugging, logging, memory management, bit manipulation, and more. + +## 📄 Documentation + +Dive into the full documentation [here](./Docs.md). + +## 🔧 Usage Example + +Below is a single example demonstrating the usage of several common macros provided by `gcml`. This example includes logging, memory management, bit manipulation, assertions, and looping constructs. + +```cpp +#include "gcml.h" + +typedef struct { + int id; + char name[50]; +} Person; + +DEPRECATED("Use new_function() instead.") +void old_function() { + LOG_WARN("This function is deprecated."); +} + +int main() { + // Logging + LOG_INFO("Application started."); + + // Memory Management + int *numbers = NULL; + SAFE_MALLOC(numbers, sizeof(int) * 5); + for(int i = 0; i < 5; ++i) { + numbers[i] = i * i; + } + LOG_INFO("Allocated numbers array."); + + // Bit Manipulation + unsigned int flags = 0; + SET_BIT(flags, 1); + LOG_INFO("Flags after setting bit 1: %u", flags); + if (CHECK_BIT(flags, 1)) { + LOG_INFO("Bit 1 is set."); + } + TOGGLE_BIT(flags, 1); + LOG_INFO("Flags after toggling bit 1: %u", flags); + + // Assertions + ASSERT(numbers != NULL, "Memory allocation failed for numbers."); + + // Loop Constructs + int arr[] = {10, 20, 30, 40, 50}; + int *item; + FOREACH(item, arr) { + LOG_INFO("Array element: %d", *item); + } + + // Using Deprecated Function + old_function(); + + // Cleanup + SAFE_FREE(numbers); + LOG_INFO("Memory freed. Application exiting."); + + return 0; +} +``` + +--- + +## 📝 License + +This project is licensed under the [MIT License](./LICENSE). + +--- + +Feel free to contribute by opening issues or submitting pull requests. For more details, refer to the [documentation](./Docs.md). \ No newline at end of file