# C-like -\> wasm as a crate?

**URL:** <https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641>\
**Category:** uncategorized\
**Created:** [October 26, 2020, 1:58am UTC](https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641 "2020-10-26T01:58:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon80458984](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon80458984](https://users.rust-lang.org/u/anon80458984)\
**Post date:** [October 26, 2020, 1:58am UTC](https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641/1 "2020-10-26T01:58:05Z")

</div>

Is there a crate that does (subset of C) -\> wasm and then returns a function we can call? I'm looking for a function of type signature:

```rust
fn compile_at_runtime(code: &str) -> Result<MyFunc, Err>;
type MyFunc = Rc<dyn Fn(int n, void **); // n args, each is a void *

```

I would prefer to do this using Rust crates (i.e. not making a shell call to gcc / llvm).

---

<div class="post-metadata">

**Author:** ![s3bk](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/s3bk/32/16472_2.png) [@s3bk](https://users.rust-lang.org/u/s3bk)\
**Post date:** [October 26, 2020, 11:55am UTC](https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641/2 "2020-10-26T11:55:32Z")

</div>

That is called a compiler 😉

C is not a terribly difficult language and wasm is not that difficult either.  
You could probably write one in a few weeks.

[no results on lib.rs](https://lib.rs/search?q=c+compiler).

---

<div class="post-metadata">

**Author:** ![s3bk](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/s3bk/32/16472_2.png) [@s3bk](https://users.rust-lang.org/u/s3bk)\
**Post date:** [October 26, 2020, 12:48pm UTC](https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641/3 "2020-10-26T12:48:48Z")

</div>

maybe look at  
[https://github.com/maierfelix/mini-c](https://github.com/maierfelix/mini-c)  
?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [January 24, 2021, 12:48pm UTC](https://users.rust-lang.org/t/c-like-wasm-as-a-crate/50641/4 "2021-01-24T12:48:50Z")

</div>

Closed on January 24, 2021, 12:48pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
