{"id":19387465,"url":"https://github.com/alphatechnolog/libcommon","last_synced_at":"2026-02-07T10:04:49.423Z","repository":{"id":251983389,"uuid":"836027141","full_name":"AlphaTechnolog/libcommon","owner":"AlphaTechnolog","description":"libcommon is a simple library which contains abstractions for some utilities such as dynamic arrays, optionals, defer statements, etc","archived":false,"fork":false,"pushed_at":"2024-08-22T14:00:45.000Z","size":46,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T17:45:17.485Z","etag":null,"topics":["c"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlphaTechnolog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-07-31T02:43:04.000Z","updated_at":"2024-08-22T14:00:48.000Z","dependencies_parsed_at":"2024-08-07T00:30:24.898Z","dependency_job_id":"de1d06ac-fe76-4ef7-b662-9c81a65edc40","html_url":"https://github.com/AlphaTechnolog/libcommon","commit_stats":null,"previous_names":["alphatechnolog/libcommon"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AlphaTechnolog/libcommon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaTechnolog%2Flibcommon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaTechnolog%2Flibcommon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaTechnolog%2Flibcommon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaTechnolog%2Flibcommon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlphaTechnolog","download_url":"https://codeload.github.com/AlphaTechnolog/libcommon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlphaTechnolog%2Flibcommon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29191997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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"],"created_at":"2024-11-10T10:09:18.127Z","updated_at":"2026-02-07T10:04:49.409Z","avatar_url":"https://github.com/AlphaTechnolog.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Libcommon\n\nlibcommon is a simple C library which provides abstractions for dynamic arrays, optionals, defer statements, etc.\n\n## Linking against libcommon\n\nFirst you will have to build the library, this example assumes you have a folder (git initialised) with something like this:\n\n```\nsrc\n  main.c\nextern\n```\n\nso you will have to do something like this to build the project\n\n```sh\ncat \u003c\u003c \"EOF\" \u003e src/main.c\n#include \u003cstdio.h\u003e\n#define LIBCOMMON_ENABLE_EXPERIMENTAL_DEFER\n#include \u003clibcommon.h\u003e\n\ntypedef struct person_t {\n    const char *name;\n    const char *lastname;\n} *Person;\n\nPerson new_person(const char *name, const char *lastname) {\n    Person self = Common_dsmalloc(Person);\n    self-\u003ename = name;\n    self-\u003elastname = lastname;\n    return self;\n}\n\nint main() {\n    Optional opt_person = Common_optional_alloc_with((void*) new_person(\"John\", \"Doe\"));\n    defer({ Common_optional_free(opt_person); });\n\n    if (Common_optional_is_some(opt_person)) {\n        const Person john = Common_optional_unpack(opt_person);\n        printf(\"Hello %s %s\\n\", john-\u003ename, john-\u003elastname);\n    }\n}\nEOF\n\ncd extern\ngit submodule add https://github.com/alphatechnolog/libcommon libcommon\ncd libcommon\nmake\ncd ../../\n\ncc -c -o main.o src/main.c -Iextern/libcommon/include -O3 -Werror -Wall\ncc -o application main.o -Lextern/libcommon/lib -lcommon\n./application\n```\n\nSo this was an example of using libcommon's optionals and the defer statement provided by libcommon... take in mind that enabling\nlibcommon's defer statement can be problematic if you're targeting another compiler different than gcc, this is because defer atm is only supported for gcc because of how the macro is done. Anyways, I am still working on porting it for other compilers :(\n\n## Documentation\n\nPretty WIP rn but you can take a look at the [examples](./examples) in the source code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphatechnolog%2Flibcommon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falphatechnolog%2Flibcommon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falphatechnolog%2Flibcommon/lists"}