emscripten-core / emscripten-core/emscripten

EM_ASM does not support 64 bit arguments

Open
#15,828 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

This compiles:
```
#include
#include
#include

EM_JS(void, printnum, (int64_t num), {
console.log(num);
})

int main() {
int64_t num = std::numeric_limits::max();
printnum (num);
}
```
But this does not:
```
int main() {
int64_t num = std::numeric_limits::max();

EM_ASM({
console.log($0);
}, num);
}
```
The error message:
```
/Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/em_asm.h:171:98: error: no member named 'value' in '__em_asm_sig'
const char __em_asm_sig_builder<__em_asm_type_tuple >::buffer[] = { __em_asm_sig::value..., 0 };
~~~~~~~~~~~~~~~~~~~~^
../main.cpp:13:2: note: in instantiation of static data member '__em_asm_sig_builder<__em_asm_type_tuple>::buffer' requested here
EM_ASM({
^
/Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/em_asm.h:191:76: note: expanded from macro 'EM_ASM'
#define EM_ASM(code, ...) ((void)emscripten_asm_const_int(CODE_EXPR(#code) _EM_ASM_PREP_ARGS(__VA_ARGS__)))
^
/Volumes/SSD/git/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/em_asm.h:177:80: note: expanded from macro '_EM_ASM_PREP_ARGS'
, __em_asm_sig_builder<__typeof__(__em_asm_make_type_tuple(__VA_ARGS__))>::buffer, ##__VA_ARGS__
```
I believe this wouldn't be too difficult to fix, but I'd appreciate some pointers!

**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.0.0 (3fd52e107187b8a169bb04a02b9f982c8a075205)
clang version 14.0.0 (https://github.com/llvm/llvm-project 4348cd42c385e71b63e5da7e492172cff6a79d7b)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Volumes/SSD/git/emsdk/upstream/bin
```
**Failing command line in full:**
```
emcc -sWASM_BIGINT main.cpp -o main.js
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.