{"id":20989394,"url":"https://github.com/ralxyz/extern-c","last_synced_at":"2025-08-20T22:32:50.391Z","repository":{"id":119074088,"uuid":"396058905","full_name":"RalXYZ/extern-C","owner":"RalXYZ","description":"Mix C with other programming languages","archived":false,"fork":false,"pushed_at":"2021-08-15T09:58:37.000Z","size":13,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-15T17:12:01.552Z","etag":null,"topics":[],"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/RalXYZ.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-08-14T16:05:07.000Z","updated_at":"2022-03-25T16:30:27.000Z","dependencies_parsed_at":"2023-05-31T21:16:09.024Z","dependency_job_id":null,"html_url":"https://github.com/RalXYZ/extern-C","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/RalXYZ%2Fextern-C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RalXYZ%2Fextern-C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RalXYZ%2Fextern-C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RalXYZ%2Fextern-C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RalXYZ","download_url":"https://codeload.github.com/RalXYZ/extern-C/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230462915,"owners_count":18229865,"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-11-19T06:24:42.707Z","updated_at":"2024-12-19T16:16:45.603Z","avatar_url":"https://github.com/RalXYZ.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `extern \"C\"`\nThis project demonstrates how to mix C with other programming languages. \nIt aims to create a [Rosetta Stone](https://en.wikipedia.org/wiki/Rosetta_Stone) of the procedure shown in the following pseudocode:  \n\n```go\n// use programming language x\n\nfunc main() {\n    caller_language := \"x-language\";\n    caller_stack := generate_random_number();\n    println(\"[%04d] start of x-language main procedure\", caller_stack);\n\n    y_language_procedure(caller_language, caller_stack);\n\n    println(\"[{%04d}] end of x-language main procedure\", caller_stack);\n}\n```\n\n```fortran\n! use programming language y\n\nFUNCTION y_language_procedure(caller_language, caller_stack)\n    callee_stack = generate_random_number()\n    PRINT \"[%04d] start of a y-language procedure, called by [%04d], %s\", callee_stack, caller_language, caller_stack\n\n    PRINT \"[%04d] start of a y-language procedure\", callee_stack\nEND FUNCTION y_language_procedure\n```\n\nAs shown above, the main function written in x language calls a function written in y language. The output of the whole procedure looks like this:  \n\n```\n[4199] start of x-language main procedure\n[8549] start of a y-language procedure, called by x-language [4199]\n[8549] end of a y-language procedure\n[4199] end of x-language main procedure\n```\n\nThe cross-language API, as mentioned above, needs to receive a integer and a string, in order to show their basic ability of mix programming.  \n\n**All the callee procedures will be archived into static libraries using their own toolchain.** For example, to build a C static library, instead of using `cargo`, we use `gcc`.  \n\nCurrently implemented:  \n\n| Caller | Callee |\n| :----: | :----: |\n| C | golang |\n| C | rust |\n| golang | C |\n| rust | C |  \n\nWill implement:  \n- C++\n\n## Usage\nFisrtly, change directory to one of the `x-call-y`. If you want to build all `x-call-y`s, just stay in the root directory.  \n\nTo build the project:  \n\n```shell\nmake\n```\n\nTo clean the build targets:\n\n```shell\nmake clean\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralxyz%2Fextern-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralxyz%2Fextern-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralxyz%2Fextern-c/lists"}