https://github.com/codewithmirza/c2wasm
Compiling some C code to Wasm(WebAssembly), then calling it from a web app.
https://github.com/codewithmirza/c2wasm
c wasm web
Last synced: about 2 months ago
JSON representation
Compiling some C code to Wasm(WebAssembly), then calling it from a web app.
- Host: GitHub
- URL: https://github.com/codewithmirza/c2wasm
- Owner: codewithmirza
- License: apache-2.0
- Created: 2024-03-19T14:05:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T19:49:56.000Z (about 2 years ago)
- Last Synced: 2025-10-30T19:47:14.524Z (8 months ago)
- Topics: c, wasm, web
- Language: CSS
- Homepage: https://codewithmirza.github.io/c2wasm/
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WebAssembly Function Call Example
This is a simple project demonstrating how to compile a C function to WebAssembly (WASM) using Emscripten and call it from a web application.
## Project Structure
- **functions.c**: Contains a simple C function to add two numbers.
- **index.html**: HTML file for the web application.
- **script.js**: JavaScript file to load and call the WebAssembly module.
- **styles.css**: For styling the web application.
- **functions.wasm**: Compiled WebAssembly module generated from `functions.c`.
- **README.md**: Documentation for the project.
## Steps to Run
1. **Compile C Function to WebAssembly**:
- Use Emscripten to compile `functions.c` to WebAssembly:
```
emcc functions.c -o functions.wasm"
```
2. **Access the Web Application**:
- Open the GitHub Pages website connected to this repository [here](https://codewithmirza.github.io/c2wasm/).
## Usage
- Enter two numbers in the input fields and click the "Add" button to see the result.
## Additional Notes
- Experiment with different C functions and compile them to WebAssembly for use in web applications.
- Explore more advanced features and optimizations offered by Emscripten for WebAssembly development.