Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/browser_test_hello_world.c
4128 views
1
/*
2
* Copyright 2015 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
8
#include <stdio.h>
9
10
#include <emscripten.h>
11
12
int main() {
13
EM_ASM({
14
Module['prints'] = [];
15
16
var real = out;
17
18
out = function(x) {
19
real(x);
20
Module['prints'].push(x);
21
}
22
});
23
printf("hello, world!\n");
24
EM_ASM({
25
if (Module['prints'].length !== 1) throw 'bad length ' + Module['prints'].length;
26
if (Module['prints'][0] !== 'hello, world!') throw 'bad contents: ' + Module['prints'][0];
27
});
28
#ifdef REPORT_RESULT
29
REPORT_RESULT(0);
30
#endif
31
return 0;
32
}
33
34
35