Why does the number become negative in JS and what would be required for 
this to work?

I did compile with -sWASM_BIGINT.


On Wednesday, 20 October 2021 at 11:49:36 UTC+2 Márton Marczell wrote:

> Hi,
>
> Given this example code:
>
> #include <iostream>
> #include <emscripten.h>
>
> #define MYINT64 uint64_t
>
> extern "C" void EMSCRIPTEN_KEEPALIVE bar (MYINT64 n) {
>     std::cout << "C++ called from JS: " << n << std::endl;
> }
>
> EM_JS(void, foo, (MYINT64 i), {
>     console.log("JS", i, typeof(i));
>
>     Module.ccall('bar', null, ['number'], [i]);
> });
>
> int main() {
>     auto some = std::numeric_limits<MYINT64>::max();
>     std::cout << "C++ " << some << std::endl;
>     foo(some);
> }
>
> The code prints:
>
> C++ 18446744073709551615
> JS -1n bigint
> C++ called from JS: 18446744073709551615
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/0404376e-ceb8-44fb-a4dc-8f1184d3b859n%40googlegroups.com.

Reply via email to