Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created March 5, 2019 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjfish/ccf3295e66f70b1486995c3242af02dd to your computer and use it in GitHub Desktop.
Save bjfish/ccf3295e66f70b1486995c3242af02dd to your computer and use it in GitHub Desktop.
// Read the wasm file bytes
FILE *file = fopen("wasm-sample-app/target.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);
// Creates a WebAssembly Instance from wasm bytes and imports
wasmer_instance_t *instance = NULL;
wasmer_result_t compile_result = wasmer_instantiate(&instance, bytes, len, imports, 3);
printf("Compile result: %d\n", compile_result);
if (compile_result != WASMER_OK)
{
print_wasmer_error();
}
assert(compile_result == WASMER_OK);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment