Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile webassembly.h from cpp file #9

Closed
ejmurra opened this issue Jun 7, 2017 · 1 comment
Closed

Can't compile webassembly.h from cpp file #9

ejmurra opened this issue Jun 7, 2017 · 1 comment

Comments

@ejmurra
Copy link

ejmurra commented Jun 7, 2017

wa compile throws 4 errors when trying to compile a c++ file that imports the webassembly header.

You can reproduce it by copying the example code in the readme into a file named program.cpp and trying to run wa compile -o program.wasm program.cpp.

Output:

Compiling on darwin-x64 ...

clang program.cpp 
 -c 
 --target=wasm32-unknown-unknown 
 -emit-llvm 
 -nostdinc 
 -nostdlib 
 -D WEBASSEMBLY 
 -isystem /Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include 
 -o /var/folders/ts/rnwyskln05vg3cbkgl5d4s5xb72qlv/T/wa1_1788ixvKyawdM9VX.tmp

In file included from program.cpp:1:
In file included from /Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include/webassembly.h:16:
/Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include/uchar.h:17:35: error: C++ requires a type specifier for all declarations
size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict);
                                  ^
/Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include/uchar.h:18:17: error: unknown type name 'char16_t'
size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
                ^
/Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include/uchar.h:20:35: error: C++ requires a type specifier for all declarations
size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict);
                                  ^
/Users/emurray/.nvm/versions/node/v7.7.3/lib/node_modules/webassembly/include/uchar.h:21:17: error: unknown type name 'char32_t'
size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
                ^
4 errors generated.

I've also tried extern "C" the header with the same result (and it looks like you've externed all the header files anyway.)

I should also note that I'm very new to c, cpp and learning just to play with wasm so it's very likely that I've made a silly error.

@dcodeIO
Copy link
Owner

dcodeIO commented Jun 7, 2017

In the current state of this project, C++ support is still far away. It's specifically targeting C only and also doesn't include any sort of C++ standard library.

For now you are better off using emscripten if C++ support is of importance to you.

@dcodeIO dcodeIO closed this as completed Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants