{"id":51516748,"url":"https://github.com/mahdialmusaad/cutils","last_synced_at":"2026-07-08T12:30:31.099Z","repository":{"id":362574187,"uuid":"1246080808","full_name":"mahdialmusaad/cutils","owner":"mahdialmusaad","description":"A portable C utilities library.","archived":false,"fork":false,"pushed_at":"2026-06-28T21:04:53.000Z","size":807,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-28T23:05:54.034Z","etag":null,"topics":["c","library","portable","utility"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mahdialmusaad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-21T21:18:02.000Z","updated_at":"2026-06-28T21:04:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mahdialmusaad/cutils","commit_stats":null,"previous_names":["mahdialmusaad/cutils"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mahdialmusaad/cutils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdialmusaad%2Fcutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdialmusaad%2Fcutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdialmusaad%2Fcutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdialmusaad%2Fcutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mahdialmusaad","download_url":"https://codeload.github.com/mahdialmusaad/cutils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdialmusaad%2Fcutils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35265380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-08T02:00:06.796Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","library","portable","utility"],"created_at":"2026-07-08T12:30:30.342Z","updated_at":"2026-07-08T12:30:31.088Z","avatar_url":"https://github.com/mahdialmusaad.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n[![CMake on multiple platforms](https://github.com/mahdialmusaad/cutils/actions/workflows/cmake-multi-platform.yml/badge.svg)](https://github.com/mahdialmusaad/cutils/actions/workflows/cmake-multi-platform.yml)\n\nA portable C utilities library.\n\nThis offers identification macros, wrappers for OS-specific functions and other QOL additions for your C projects, simplifying writing applications by not having to worry about coding and testing multiple implementations for different systems.\n\n## Features\n\n### Identification macros\nMacros are available for identifying the following:\n\n- Compiler\n- Operating system\n- Architecture\n- Platform\n- Endianness and data model\n\nVersion values for compilers are simplified into a major, minor and revision format.\n\n### Functions\nFunctions are provided for tasks that simplify development or those that are OS/compiler specific:\u003cbr\u003e\n\n- String and path functions\n- Container functions\n- File management functions\n- Cryptographic RNG\n- Hardware and OS information functions\n- Time-related functions\n- Networking functions\n- Threading and synchronization functions\n\nAn example of a chat server and client is provided in the following [file](examples/network.c).\n\nYou can selectively disable certain function groups by defining their specific `CU_SETTING_*_FUNCS` macro to `0`:\n```c\n/* The #define has to occur before any inclusion of cutils.h.\n   You can also define it in your compiler directly. */\n#define CU_SETTING_NETWORK_FUNCS 0\n#include \"cutils.h\"\n```\n\n### Optimization and Debugging\nMacros are also available for simplifying optimizing and debugging your code:\n\n- Assertion macros (compile and run-time)\n- Function attributes (e.g. const, nothrow)\n- Branch prediction and assumption macros\n- Compiler diagnostic macros\n- Explicit breakpoints and traps\n\n### QOL macros\nFinally, there are some general macros for ease of development:\n\n- Keywords (thread_local, restrict)\n- Feature availability (keywords, compiler macros, builtins)\n- Fixed-width integers (i32, u64, etc), with their respective formats and maximum values\n- C version checking\n\nThe macros are also written in such a way to simplify checks:\n\n```c\n#if CU_OS_LINUX\n/* Compiled on Linux */\n#elif CU_COMPILER_ISVER(GCC, 8, 1)\n/* Compiler is based on GCC 8.1 or higher */\n#elif CU_ARCH_X86\n/* Compiled for the x86 architecture */\n```\n\n## Support\nThis is mostly aimed towards being used for writing C code that can be compiled for Linux, MacOS and Windows as well as on major compilers without needing to write specific code for each - the source code is written in C89 and checks for feature support so any reasonable compiler should have no problem compiling it.\n\nIf you are attempting to build the library yourself but your system does not provide the required functionality, a warning will be emitted and the functions affected will not be available.\n\n## Building\nYou can download the static library from the Releases section for each version. \u003cbr\u003e\nAlternatively, both a [CMakeLists.txt](CMakeLists.txt) and [Makefile](Makefile) are provided to build the library:\n\n```bash\n# Using CMake (omit '-DCU_BUILD_MISC=1' to only build the library):\n$ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCU_BUILD_MISC=1\n$ cmake --build build --config Release\n\n# Using make (omit 'all' to only build the library):\n$ make all\n```\nResults can be found in the `build` directory. \u003cbr\u003e\nAdditional documentation can be found in the respective build files.\n\n## Sources\nMost identification macros are from [predef](https://github.com/cpredef/predef) and [Boost](https://www.boost.org/doc/libs/latest/libs/predef/doc/index.html).\u003cbr\u003e\nOptimization macros and some attributes are from [Hedley](https://github.com/nemequ/hedley).\u003cbr\u003e\nOther macros are from own tests and may have incorrect detection.\n\n## Changelog\n### cu3\n- Added thread pool/split, condition variables, directory listing and user/host name retrieval\n- Various bug fixes relating to functions and macros\n- Improved support for MacOS specific functionality\n- Removed obsolete features\n- Changed test and examples format\n\n### cu2\n- Networking functions added with chat server example\n- custr_findnot, cu_res_osname and cu_thread_self added\n- Reduced code size of string functions and fixed memory leaks for Unix functions\n- Minor formatting changes to sources and debug allocation functions\n- CMakeLists.txt added\n- 'Releases' packaging changes\n\n### cu1\n- Initial release of cutils library\n- Identification, debugging/optimization and QOL macros\n- String/path, file, RNG, hardware, time, threading and allocation functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdialmusaad%2Fcutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahdialmusaad%2Fcutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdialmusaad%2Fcutils/lists"}