{"id":16880756,"url":"https://github.com/wtdcode/closure2fp","last_synced_at":"2025-08-30T15:06:20.751Z","repository":{"id":110680985,"uuid":"390808396","full_name":"wtdcode/closure2fp","owner":"wtdcode","description":"An example to illustrate how libffi cast a closure to a pointer to function.","archived":false,"fork":false,"pushed_at":"2021-07-30T08:42:09.000Z","size":11,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T08:04:31.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/wtdcode.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}},"created_at":"2021-07-29T17:53:21.000Z","updated_at":"2025-02-26T12:09:51.000Z","dependencies_parsed_at":"2023-04-10T21:30:45.092Z","dependency_job_id":null,"html_url":"https://github.com/wtdcode/closure2fp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Fclosure2fp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Fclosure2fp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Fclosure2fp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Fclosure2fp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wtdcode","download_url":"https://codeload.github.com/wtdcode/closure2fp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248387137,"owners_count":21095160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-13T15:59:59.110Z","updated_at":"2025-04-11T11:44:29.386Z","avatar_url":"https://github.com/wtdcode.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# closure2fp\n\nAn example to illustrate how libffi cast a closure to a pointer to function. Note that this only works on Linux x86_64.\n\nBlog post link:\n\n- [Cast a Closure to a Function Pointer -- How libffi closure works](https://blog.lazym.io/2021/07/29/Cast-a-Closure-to-a-Function-Pointer-How-libffi-closure-works/)\n- [把闭包变成函数指针 ——libffi 闭包原理解析](https://blog.ihomura.cn/2021/07/30/%E6%8A%8A%E9%97%AD%E5%8C%85%E5%8F%98%E6%88%90%E5%87%BD%E6%95%B0%E6%8C%87%E9%92%88%E2%80%94%E2%80%94libffi-%E9%97%AD%E5%8C%85%E5%8E%9F%E7%90%86%E8%A7%A3%E6%9E%90/)\n\n# Sources\n\n- closure.c closure.h: The closure lib to cast a closure to a raw function pointer.\n- lib.c lib.h: The lib that provides API to register callback.\n- main.c: The example that uses lib.h well-designed callback API.\n- main.cpp: The example that uses lib.c well-designed callback API with a cpp wrapper.\n- main_bad.c: The example that uses lib.h bad-designed callback API.\n- main_bad.cpp: The example that uses lib.c bad-designed callback API with a cpp wrapper.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtdcode%2Fclosure2fp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwtdcode%2Fclosure2fp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtdcode%2Fclosure2fp/lists"}