Created
March 5, 2019 04:44
-
-
Save bjfish/ccf3295e66f70b1486995c3242af02dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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