mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
27 lines
661 B
C
27 lines
661 B
C
#include <stdio.h>
|
|
#include "../wasmer.h"
|
|
#include <assert.h>
|
|
#include <stdint.h>
|
|
|
|
int main()
|
|
{
|
|
// Read the wasm file bytes
|
|
FILE *file = fopen("sum.wasm", "r");
|
|
fseek(file, 0, SEEK_END);
|
|
long len = ftell(file);
|
|
uint8_t *bytes = malloc(len);
|
|
fseek(file, 0, SEEK_SET);
|
|
fread(bytes, 1, len, file);
|
|
fclose(file);
|
|
|
|
wasmer_module_t *module = NULL;
|
|
wasmer_result_t compile_result = wasmer_compile(&module, bytes, len);
|
|
printf("Compile result: %d\n", compile_result);
|
|
assert(compile_result == WASMER_OK);
|
|
|
|
// TODO add module exports
|
|
|
|
printf("Destroy module\n");
|
|
wasmer_module_destroy(module);
|
|
return 0;
|
|
} |