Skip to content

Commit 9832932

Browse files
authored
Expose greeting helpers for WebAssembly (#15)
1 parent dc35806 commit 9832932

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

wasm/hello.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
#include <stdio.h>
1+
#include <stddef.h>
2+
#include <emscripten/emscripten.h>
23

3-
int main(void)
4+
static const char GREETING[] = "Hello from WebAssembly!";
5+
6+
EMSCRIPTEN_KEEPALIVE
7+
const char *get_greeting(void)
8+
{
9+
return GREETING;
10+
}
11+
12+
EMSCRIPTEN_KEEPALIVE
13+
size_t get_greeting_length(void)
414
{
5-
printf("Hello, world!\n");
6-
return 0;
15+
return sizeof(GREETING) - 1;
716
}

0 commit comments

Comments
 (0)